Skip to content

Commit

Permalink
rv_histogram: Make it more verbose
Browse files Browse the repository at this point in the history
Section headers must be present for static analysis

Closed #272
  • Loading branch information
ChinYikMing committed Nov 23, 2023
1 parent dd7ce2e commit 83961c3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tools/rv_histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,32 @@ static void insn_hist_incr(const rv_insn_t *ir)

int main(int argc, const char *args[])
{
int ret_val = 0;

if (!parse_args(argc, args) || !elf_prog) {
print_usage(args[0]);
return 1;
ret_val = 1;
goto end;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.1 rule Note

MISRA 15.1 rule
}

/* resolver of histogram accounting */
hist_record_handler hist_record = show_reg ? reg_hist_incr : insn_hist_incr;

elf_t *e = elf_new();
if (!elf_open(e, elf_prog)) {
fprintf(stderr, "elf_open failed\n");
return 1;
(void) fprintf(stderr, "elf_open %s failed\n", elf_prog);
ret_val = 1;
goto end;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.1 rule Note

MISRA 15.1 rule
}

struct Elf32_Ehdr *hdr = get_elf_header(e);
if (!hdr->e_shnum) {
(void) fprintf(stderr, "no section headers are found in %s\n",
elf_prog);
ret_val = 1;
goto end;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.1 rule Note

MISRA 15.1 rule
}

uint8_t *elf_first_byte = get_elf_first_byte(e);
const struct Elf32_Shdr **shdrs =
(const struct Elf32_Shdr **) &elf_first_byte[hdr->e_shoff];
Expand Down Expand Up @@ -317,5 +328,6 @@ int main(int argc, const char *args[])

elf_delete(e);

return 0;
end:
return !!ret_val;
}

0 comments on commit 83961c3

Please sign in to comment.