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>
This commit is contained in:
parent
552c8c5971
commit
01b42b2e7c
|
@ -105,7 +105,6 @@ static bool read_varlen(FILE *f, int c, unsigned *value)
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned size;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
*value = 0;
|
*value = 0;
|
||||||
|
|
||||||
|
@ -136,14 +135,13 @@ static bool read_varlen(FILE *f, int c, unsigned *value)
|
||||||
|
|
||||||
err:
|
err:
|
||||||
printf("(ERROR %d - %s)\n", errno, strerror(errno));
|
printf("(ERROR %d - %s)\n", errno, strerror(errno));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_hard(FILE *f, int c)
|
static void show_hard(FILE *f, int c)
|
||||||
{
|
{
|
||||||
unsigned type = c >> 3;
|
unsigned type = c >> 3;
|
||||||
unsigned value;
|
unsigned value;
|
||||||
unsigned size;
|
|
||||||
char *label;
|
char *label;
|
||||||
|
|
||||||
printf("DWT - ");
|
printf("DWT - ");
|
||||||
|
@ -241,9 +239,7 @@ struct {
|
||||||
|
|
||||||
static void show_swit(FILE *f, int c)
|
static void show_swit(FILE *f, int c)
|
||||||
{
|
{
|
||||||
unsigned size;
|
|
||||||
unsigned port = c >> 3;
|
unsigned port = c >> 3;
|
||||||
unsigned char buf[4];
|
|
||||||
unsigned value = 0;
|
unsigned value = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -253,7 +249,7 @@ static void show_swit(FILE *f, int c)
|
||||||
return;
|
return;
|
||||||
printf("%#08x", value);
|
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) {
|
if (format[i].port == port) {
|
||||||
printf(", ");
|
printf(", ");
|
||||||
format[i].show(port, value);
|
format[i].show(port, value);
|
||||||
|
@ -263,10 +259,6 @@ static void show_swit(FILE *f, int c)
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
err:
|
|
||||||
printf("(ERROR %d - %s)\n", errno, strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_timestamp(FILE *f, int c)
|
static void show_timestamp(FILE *f, int c)
|
||||||
|
@ -367,7 +359,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage:
|
|
||||||
fprintf(stderr, "usage: %s [-f input]",
|
fprintf(stderr, "usage: %s [-f input]",
|
||||||
basename(argv[0]));
|
basename(argv[0]));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue