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>
__archive__
Paul Fertser 2015-02-06 18:28:56 +03:00
parent 552c8c5971
commit 01b42b2e7c
1 changed files with 2 additions and 11 deletions

View File

@ -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;