|
From: <zw...@ma...> - 2009-05-21 11:29:09
|
Author: zwelch
Date: 2009-05-21 11:28:57 +0200 (Thu, 21 May 2009)
New Revision: 1873
Modified:
trunk/src/flash/flash.c
trunk/src/flash/nand.c
trunk/src/helper/command.h
trunk/src/pld/pld.c
trunk/src/svf/svf.c
trunk/src/target/armv4_5.c
trunk/src/target/armv4_5_mmu.c
trunk/src/target/etm.c
trunk/src/target/target.c
trunk/src/target/trace.c
Log:
David Brownell <da...@pa...>: This patch adds annotations to
the key command_*() helper functions, fixng the bugs that turned up.
Several of these bugs were from misuse of PRIi64; that's for 64-bit
integers, NOT for "long long" or "u64" (which work best with %lld).
Modified: trunk/src/flash/flash.c
===================================================================
--- trunk/src/flash/flash.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/flash/flash.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -432,7 +432,7 @@
int j;
if ((retval = p->driver->erase_check(p)) == ERROR_OK)
{
- command_print(cmd_ctx, "successfully checked erase state", p->driver->name, p->base);
+ command_print(cmd_ctx, "successfully checked erase state");
}
else
{
@@ -567,7 +567,8 @@
return retval;
}
- command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %s", first, last, strtoul(args[0], 0, 0), duration_text);
+ command_print(cmd_ctx, "erased sectors %i through %i on flash bank %li in %s",
+ first, last, strtoul(args[0], 0, 0), duration_text);
free(duration_text);
}
}
@@ -606,7 +607,9 @@
retval = flash_driver_protect(p, set, first, last);
if (retval == ERROR_OK)
{
- command_print(cmd_ctx, "%s protection for sectors %i through %i on flash bank %i", (set) ? "set" : "cleared", first, last, strtoul(args[0], 0, 0));
+ command_print(cmd_ctx, "%s protection for sectors %i through %i on flash bank %li",
+ (set) ? "set" : "cleared", first,
+ last, strtoul(args[0], 0, 0));
}
}
else
@@ -873,7 +876,7 @@
}
if (retval==ERROR_OK)
{
- command_print(cmd_ctx, "wrote %"PRIi64" byte from file %s to flash bank %i at offset 0x%8.8x in %s (%f kb/s)",
+ command_print(cmd_ctx, "wrote %lld byte from file %s to flash bank %li at offset 0x%8.8x in %s (%f kb/s)",
fileio.size, args[1], strtoul(args[0], NULL, 0), offset, duration_text,
(float)fileio.size / 1024.0 / ((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0)));
}
Modified: trunk/src/flash/nand.c
===================================================================
--- trunk/src/flash/nand.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/flash/nand.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -1148,7 +1148,7 @@
}
else
{
- command_print(cmd_ctx, "#%i: not probed");
+ command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
@@ -1251,7 +1251,7 @@
{
if ((retval = nand_build_bbt(p, first, last)) == ERROR_OK)
{
- command_print(cmd_ctx, "checked NAND flash device for bad blocks, use \"nand info\" command to list blocks", p->device->name);
+ command_print(cmd_ctx, "checked NAND flash device for bad blocks, use \"nand info\" command to list blocks");
}
else if (retval == ERROR_NAND_OPERATION_FAILED)
{
@@ -1570,13 +1570,13 @@
fileio_close(&fileio);
duration_stop_measure(&duration, &duration_text);
- command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text);
+ command_print(cmd_ctx, "dumped %lld byte in %s", fileio.size, duration_text);
free(duration_text);
duration_text = NULL;
}
else
{
- command_print(cmd_ctx, "#%i: not probed");
+ command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
else
@@ -1621,7 +1621,7 @@
}
else
{
- command_print(cmd_ctx, "#%i: not probed");
+ command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
else
Modified: trunk/src/helper/command.h
===================================================================
--- trunk/src/helper/command.h 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/helper/command.h 2009-05-21 09:28:57 UTC (rev 1873)
@@ -83,10 +83,14 @@
extern int command_context_mode(command_context_t *context, enum command_mode mode);
extern command_context_t* command_init(void);
extern int command_done(command_context_t *context);
-extern void command_print(command_context_t *context, char *format, ...);
-extern void command_print_sameline(command_context_t *context, char *format, ...);
+
+extern void command_print(command_context_t *context, char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
+extern void command_print_sameline(command_context_t *context, char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
extern int command_run_line(command_context_t *context, char *line);
-extern int command_run_linef(command_context_t *context, char *format, ...);
+extern int command_run_linef(command_context_t *context, char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
extern void command_output_text(command_context_t *context, const char *data);
extern void process_jim_events(void);
Modified: trunk/src/pld/pld.c
===================================================================
--- trunk/src/pld/pld.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/pld/pld.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -178,7 +178,7 @@
if ((retval = p->driver->load(p, args[1])) != ERROR_OK)
{
- command_print(cmd_ctx, "failed loading file %s to pld device %i",
+ command_print(cmd_ctx, "failed loading file %s to pld device %lu",
args[1], strtoul(args[0], NULL, 0));
switch (retval)
{
@@ -188,9 +188,10 @@
{
gettimeofday(&end, NULL);
timeval_subtract(&duration, &end, &start);
-
- command_print(cmd_ctx, "loaded file %s to pld device %i in %is %ius",
- args[1], strtoul(args[0], NULL, 0), duration.tv_sec, duration.tv_usec);
+
+ command_print(cmd_ctx, "loaded file %s to pld device %lu in %lis %lius",
+ args[1], strtoul(args[0], NULL, 0),
+ duration.tv_sec, duration.tv_usec);
}
return ERROR_OK;
Modified: trunk/src/svf/svf.c
===================================================================
--- trunk/src/svf/svf.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/svf/svf.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -330,7 +330,7 @@
}
// print time
- command_print(cmd_ctx, "%d ms used", timeval_ms() - time_ago);
+ command_print(cmd_ctx, "%lld ms used", timeval_ms() - time_ago);
free_all:
Modified: trunk/src/target/armv4_5.c
===================================================================
--- trunk/src/target/armv4_5.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/target/armv4_5.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -342,7 +342,7 @@
output_len += snprintf(output + output_len, 128 - output_len, "%8s: %8.8x ", ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).name,
buf_get_u32(ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).value, 0, 32));
}
- command_print(cmd_ctx, output);
+ command_print(cmd_ctx, "%s", output);
}
command_print(cmd_ctx, " cpsr: %8.8x spsr_fiq: %8.8x spsr_irq: %8.8x spsr_svc: %8.8x spsr_abt: %8.8x spsr_und: %8.8x",
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
Modified: trunk/src/target/armv4_5_mmu.c
===================================================================
--- trunk/src/target/armv4_5_mmu.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/target/armv4_5_mmu.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -299,7 +299,7 @@
if ((i % 8 == 7) || (i == count - 1))
{
- command_print(cmd_ctx, output);
+ command_print(cmd_ctx, "%s", output);
output_len = 0;
}
}
Modified: trunk/src/target/etm.c
===================================================================
--- trunk/src/target/etm.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/target/etm.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -1674,7 +1674,7 @@
if ((new_value < 2) || (new_value > 100))
{
- command_print(cmd_ctx, "valid settings are 2% to 100%");
+ command_print(cmd_ctx, "valid settings are 2%% to 100%%");
}
else
{
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/target/target.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -1910,7 +1910,7 @@
if ((i%line_modulo == line_modulo-1) || (i == count - 1))
{
- command_print(cmd_ctx, output);
+ command_print(cmd_ctx, "%s", output);
output_len = 0;
}
}
@@ -2168,7 +2168,8 @@
if (retval==ERROR_OK)
{
- command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text);
+ command_print(cmd_ctx, "dumped %lld byte in %s",
+ fileio.size, duration_text);
free(duration_text);
}
@@ -2369,7 +2370,8 @@
}
else
{
- command_print(cmd_ctx, "breakpoint added at address 0x%8.8x", strtoul(args[0], NULL, 0));
+ command_print(cmd_ctx, "breakpoint added at address 0x%8.8lx",
+ strtoul(args[0], NULL, 0));
}
}
else
Modified: trunk/src/target/trace.c
===================================================================
--- trunk/src/target/trace.c 2009-05-21 05:46:29 UTC (rev 1872)
+++ trunk/src/target/trace.c 2009-05-21 09:28:57 UTC (rev 1873)
@@ -60,7 +60,7 @@
for (i = 0; i < trace->num_trace_points; i++)
{
- command_print(cmd_ctx, "trace point 0x%8.8x (%"PRIi64" times hit)",
+ command_print(cmd_ctx, "trace point 0x%8.8x (%lld times hit)",
trace->trace_points[i].address,
trace->trace_points[i].hit_counter);
}
|