diff options
author | Paul Fertser <fercerpav@gmail.com> | 2015-02-06 18:28:56 +0300 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2015-03-09 06:32:17 +0000 |
commit | 01b42b2e7c0d2a0419548f0a270705dc19baca34 (patch) | |
tree | a3e396bbe4205a1bf999b5df6667c9cd16baa02b /contrib | |
parent | 552c8c5971424fd7786e91f7e0987b412a8dce53 (diff) | |
download | riscv-openocd-01b42b2e7c0d2a0419548f0a270705dc19baca34.zip riscv-openocd-01b42b2e7c0d2a0419548f0a270705dc19baca34.tar.gz riscv-openocd-01b42b2e7c0d2a0419548f0a270705dc19baca34.tar.bz2 |
contrib/itmdump: fix UB in show_swit, and few compile warnings
Change-Id: I1c5c99f190f7b4d405dc6fa06533e7ff37a652ec
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2533
Tested-by: jenkins
Reviewed-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/itmdump.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/contrib/itmdump.c b/contrib/itmdump.c index fe83549..71f6e06 100644 --- a/contrib/itmdump.c +++ b/contrib/itmdump.c @@ -105,7 +105,6 @@ static bool read_varlen(FILE *f, int c, unsigned *value) { unsigned size; unsigned char buf[4]; - unsigned i; *value = 0; @@ -136,14 +135,13 @@ static bool read_varlen(FILE *f, int c, unsigned *value) err: printf("(ERROR %d - %s)\n", errno, strerror(errno)); - return; + return false; } static void show_hard(FILE *f, int c) { unsigned type = c >> 3; unsigned value; - unsigned size; char *label; printf("DWT - "); @@ -241,9 +239,7 @@ struct { static void show_swit(FILE *f, int c) { - unsigned size; unsigned port = c >> 3; - unsigned char buf[4]; unsigned value = 0; unsigned i; @@ -253,7 +249,7 @@ static void show_swit(FILE *f, int c) return; printf("%#08x", value); - for (i = 0; i <= sizeof(format) / sizeof(format[0]); i++) { + for (i = 0; i < sizeof(format) / sizeof(format[0]); i++) { if (format[i].port == port) { printf(", "); format[i].show(port, value); @@ -263,10 +259,6 @@ static void show_swit(FILE *f, int c) printf("\n"); return; - -err: - printf("(ERROR %d - %s)\n", errno, strerror(errno)); - return; } static void show_timestamp(FILE *f, int c) @@ -367,7 +359,6 @@ int main(int argc, char **argv) } break; default: -usage: fprintf(stderr, "usage: %s [-f input]", basename(argv[0])); return 1; |