]> git.sur5r.net Git - openocd/commitdiff
David Brownell <david-b@pacbell.net>: This patch adds annotations to
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 21 May 2009 09:28:57 +0000 (09:28 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 21 May 2009 09:28:57 +0000 (09:28 +0000)
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).

git-svn-id: svn://svn.berlios.de/openocd/trunk@1873 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/flash.c
src/flash/nand.c
src/helper/command.h
src/pld/pld.c
src/svf/svf.c
src/target/armv4_5.c
src/target/armv4_5_mmu.c
src/target/etm.c
src/target/target.c
src/target/trace.c

index ff66a396f557d911639717ef935320670e1c2298..9beec5a1333d3e1421f907f06e071d6e72d16d4a 100644 (file)
@@ -432,7 +432,7 @@ static int handle_flash_erase_check_command(struct command_context_s *cmd_ctx, c
                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 @@ static int handle_flash_erase_command(struct command_context_s *cmd_ctx, char *c
                                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 @@ static int handle_flash_protect_command(struct command_context_s *cmd_ctx, char
                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 @@ static int handle_flash_write_bank_command(struct command_context_s *cmd_ctx, ch
        }
        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)));
        }
index 85ca0fed45cd35c9a5df308e5652982ae08550d7..6ca008c7f0cf94fdc533262edf8264a63ab769ff 100644 (file)
@@ -1148,7 +1148,7 @@ static int handle_nand_info_command(struct command_context_s *cmd_ctx, char *cmd
                }
                else
                {
-                       command_print(cmd_ctx, "#%i: not probed");
+                       command_print(cmd_ctx, "#%s: not probed", args[0]);
                }
        }
 
@@ -1251,7 +1251,7 @@ int handle_nand_check_bad_blocks_command(struct command_context_s *cmd_ctx, char
        {
                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 @@ static int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd
                        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 @@ static int handle_nand_raw_access_command(struct command_context_s *cmd_ctx, cha
                }
                else
                {
-                       command_print(cmd_ctx, "#%i: not probed");
+                       command_print(cmd_ctx, "#%s: not probed", args[0]);
                }
        }
        else
index 48cbdaab748cf7e46a8b27576f82d3f1bb6b5dc5..df3d37a52abba69d4d22b2ccceb38ad7179f9a50 100644 (file)
@@ -83,10 +83,14 @@ extern command_context_t* copy_command_context(command_context_t* context);
 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);
index 48638b925f54a906990d6d1d12f12f7e3f9b2f33..8b3b1ac3cdc2c5cac7e8639fd39c77a346ea47ea 100644 (file)
@@ -178,7 +178,7 @@ int handle_pld_load_command(struct command_context_s *cmd_ctx, char *cmd, char *
        
        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 @@ int handle_pld_load_command(struct command_context_s *cmd_ctx, char *cmd, char *
        {
                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;
index 1267755b9b2d8d024c4c72339b8386b1640990a0..3cad4c7e96e0970725345755652b75064273553a 100644 (file)
@@ -330,7 +330,7 @@ static int handle_svf_command(struct command_context_s *cmd_ctx, char *cmd, char
        }
 
        // 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:
 
index 14aec0198c805bbd27b05721966d1a9255ca08a4..eebf866a7ab67ff4cc57d3adf3cf7bbf424af23e 100644 (file)
@@ -342,7 +342,7 @@ int handle_armv4_5_reg_command(struct command_context_s *cmd_ctx, char *cmd, cha
                        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),
index cc8fb3a23a5fa022abc5d3fc0c0da896f491ecc2..abcd10e434ed033d78fcb4b6486e9dd310d8a2bc 100644 (file)
@@ -299,7 +299,7 @@ int armv4_5_mmu_handle_md_phys_command(command_context_t *cmd_ctx, char *cmd, ch
 
                if ((i % 8 == 7) || (i == count - 1))
                {
-                       command_print(cmd_ctx, output);
+                       command_print(cmd_ctx, "%s", output);
                        output_len = 0;
                }
        }
index 5b83db893abaeea4abf8f7db92153ac429fc106f..7cb07d6b7aca5c3203ee7a38d402248f878615b7 100644 (file)
@@ -1674,7 +1674,7 @@ static int handle_etm_trigger_percent_command(struct command_context_s *cmd_ctx,
 
                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
                {
index 3bb2fa360ec1fc8e0c5eb8a487ee7c9e155f16b9..3921e8252620dab4ec443517ea8579fc60a2bfb0 100644 (file)
@@ -1910,7 +1910,7 @@ static int handle_md_command(struct command_context_s *cmd_ctx, char *cmd, char
 
                        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 @@ static int handle_dump_image_command(struct command_context_s *cmd_ctx, char *cm
 
        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 @@ static int handle_bp_command(struct command_context_s *cmd_ctx, char *cmd, char
                }
                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
index 2e7d45804b60e601c53ecafa1c6a960095dadb1c..d0f40b2d98bfdb37f1cbe49a4c4a2ce810bec797 100644 (file)
@@ -60,7 +60,7 @@ static int handle_trace_point_command(struct command_context_s *cmd_ctx, char *c
                
                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);
                }