]> git.sur5r.net Git - openocd/commitdiff
Address codereview comment from Steve Grubb <sgrubb@redhat.com>:
authordbrownell <dbrownell@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 17 Sep 2009 19:20:18 +0000 (19:20 +0000)
committerdbrownell <dbrownell@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 17 Sep 2009 19:20:18 +0000 (19:20 +0000)
avoid a duplicate test.

Plus other cleanup in the same code: be "static", sane line lengths
for source and diagnostics, and fix misleading variable names.

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

src/jtag/core.c
src/jtag/tcl.c

index acd84e9a8e7c644826a72eb8fedb423979f291d3..97179192e5681336701047587b4d3fc59a6e093f 100644 (file)
@@ -385,7 +385,8 @@ void jtag_add_callback4(jtag_callback_t f, jtag_callback_data_t data0,
        interface_jtag_add_callback4(f, data0, data1, data2, data3);
 }
 
-int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value, uint8_t *in_check_mask, int num_bits);
+static int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value,
+               uint8_t *in_check_mask, int num_bits);
 
 static int jtag_check_value_mask_callback(jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
 {
@@ -727,7 +728,8 @@ void jtag_add_sleep(uint32_t us)
        jtag_set_error(interface_jtag_add_sleep(us));
 }
 
-int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value, uint8_t *in_check_mask, int num_bits)
+static int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value,
+               uint8_t *in_check_mask, int num_bits)
 {
        int retval = ERROR_OK;
 
@@ -739,39 +741,32 @@ int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value, uint8_t *
                compare_failed = buf_cmp(captured, in_check_value, num_bits);
 
        if (compare_failed) {
-               /* An error handler could have caught the failing check
-                * only report a problem when there wasn't a handler, or if the handler
-                * acknowledged the error
-                */
-               /*
-               LOG_WARNING("TAP %s:",
-                                       jtag_tap_name(field->tap));
-                                       */
-               if (compare_failed)
-               {
-                       char *captured_char = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
-                       char *in_check_value_char = buf_to_str(in_check_value, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
+               char *captured_str, *in_check_value_str;
+               int bits = (num_bits > DEBUG_JTAG_IOZ)
+                               ? DEBUG_JTAG_IOZ
+                               : num_bits;
 
-                       if (in_check_mask)
-                       {
-                               char *in_check_mask_char;
-                               in_check_mask_char = buf_to_str(in_check_mask, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
-                               LOG_WARNING("value captured during scan didn't pass the requested check:");
-                               LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
-                                                       captured_char, in_check_value_char, in_check_mask_char);
-                               free(in_check_mask_char);
-                       }
-                       else
-                       {
-                               LOG_WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s", captured_char, in_check_value_char);
-                       }
+               /* NOTE:  we've lost diagnostic context here -- 'which tap' */
+
+               captured_str = buf_to_str(captured, bits, 16);
+               in_check_value_str = buf_to_str(in_check_value, bits, 16);
+
+               LOG_WARNING("Bad value '%s' captured during DR or IR scan:",
+                               captured_str);
+               LOG_WARNING(" check_value: 0x%s", in_check_value_str);
+
+               free(captured_str);
+               free(in_check_value_str);
 
-                       free(captured_char);
-                       free(in_check_value_char);
+               if (in_check_mask) {
+                       char *in_check_mask_str;
 
-                       retval = ERROR_JTAG_QUEUE_FAILED;
+                       in_check_mask_str = buf_to_str(in_check_mask, bits, 16);
+                       LOG_WARNING(" check_mask: 0x%s", in_check_mask_str);
+                       free(in_check_mask_str);
                }
 
+               retval = ERROR_JTAG_QUEUE_FAILED;
        }
        return retval;
 }
@@ -974,7 +969,7 @@ static bool jtag_examine_chain_match_tap(const struct jtag_tap_s *tap)
 
 /* Try to examine chain layout according to IEEE 1149.1 ยง12
  */
-int jtag_examine_chain(void)
+static int jtag_examine_chain(void)
 {
        uint8_t idcode_buffer[JTAG_MAX_CHAIN_SIZE * 4];
        unsigned device_count = 0;
index 1658f76a264e0cf2a2c31dc52f465f4ea109d9f7..d9047ac92087a8910d6c7f921965fa6df7d5cb63 100644 (file)
@@ -75,8 +75,6 @@ static int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, ch
 static int handle_verify_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 static int handle_tms_sequence_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
-extern int jtag_examine_chain(void);
-extern int jtag_validate_chain(void);
 
 enum jtag_tap_cfg_param {
        JCFG_EVENT