From 01b42b2e7c0d2a0419548f0a270705dc19baca34 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Fri, 6 Feb 2015 18:28:56 +0300 Subject: [PATCH] contrib/itmdump: fix UB in show_swit, and few compile warnings Change-Id: I1c5c99f190f7b4d405dc6fa06533e7ff37a652ec Signed-off-by: Paul Fertser Reviewed-on: http://openocd.zylin.com/2533 Tested-by: jenkins Reviewed-by: Uwe Bonnes Reviewed-by: Spencer Oliver --- contrib/itmdump.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/contrib/itmdump.c b/contrib/itmdump.c index fe835493..71f6e067 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; -- 2.39.5