jlink: deconflict local variables from global symbols 85/3185/2
authorPeter A. Bigot <pab@pabigot.com>
Mon, 4 Jan 2016 20:37:43 +0000 (14:37 -0600)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 6 Jan 2016 20:01:28 +0000 (20:01 +0000)
BeagleBone debian 7 builds produce:
    jlink.c: In function 'jlink_speed':
    jlink.c:218:11: error: declaration of 'div' shadows a global declaration [-Werror=shadow]
    jlink.c: In function 'check_trace_freq':
    jlink.c:1065:54: error: declaration of 'div' shadows a global declaration [-Werror=shadow]
    jlink.c: In function 'config_trace':
    jlink.c:1101:11: error: declaration of 'div' shadows a global declaration [-Werror=shadow]

Fix this by changing the local variable to 'divider'.

Change-Id: I96a0cc0f7d4d4af5a56aa1e918e5416d3c61cbfe
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Reviewed-on: http://openocd.zylin.com/3185
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/jtag/drivers/jlink.c

index 04297ca07406d1d46eb38c8b074690d85a5a9d1d..84127ab54d822d5ac6a9291f016b0abb695432aa 100644 (file)
@@ -215,11 +215,11 @@ static int jlink_speed(int speed)
 {
        int ret;
        uint32_t freq;
 {
        int ret;
        uint32_t freq;
-       uint16_t div;
+       uint16_t divider;
        int max_speed;
 
        if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_SPEEDS)) {
        int max_speed;
 
        if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_SPEEDS)) {
-               ret = jaylink_get_speeds(devh, &freq, &div);
+               ret = jaylink_get_speeds(devh, &freq, &divider);
 
                if (ret != JAYLINK_OK) {
                        LOG_ERROR("jaylink_get_speeds() failed: %s.",
 
                if (ret != JAYLINK_OK) {
                        LOG_ERROR("jaylink_get_speeds() failed: %s.",
@@ -228,7 +228,7 @@ static int jlink_speed(int speed)
                }
 
                freq = freq / 1000;
                }
 
                freq = freq / 1000;
-               max_speed = freq / div;
+               max_speed = freq / divider;
        } else {
                max_speed = JLINK_MAX_SPEED;
        }
        } else {
                max_speed = JLINK_MAX_SPEED;
        }
@@ -1062,26 +1062,26 @@ static uint32_t calculate_trace_buffer_size(void)
        return tmp & 0xffffff00;
 }
 
        return tmp & 0xffffff00;
 }
 
-static bool check_trace_freq(uint32_t freq, uint32_t div, uint32_t trace_freq)
+static bool check_trace_freq(uint32_t freq, uint32_t divider, uint32_t trace_freq)
 {
        double min;
        double deviation;
 
 {
        double min;
        double deviation;
 
-       min = fabs(1.0 - (freq / ((double)trace_freq * div)));
+       min = fabs(1.0 - (freq / ((double)trace_freq * divider)));
 
 
-       while (freq / div > 0) {
-               deviation = fabs(1.0 - (freq / ((double)trace_freq * div)));
+       while (freq / divider > 0) {
+               deviation = fabs(1.0 - (freq / ((double)trace_freq * divider)));
 
                if (deviation < 0.03) {
                        LOG_DEBUG("Found suitable frequency divider %u with deviation of "
 
                if (deviation < 0.03) {
                        LOG_DEBUG("Found suitable frequency divider %u with deviation of "
-                               "%.02f %%.", div, deviation);
+                               "%.02f %%.", divider, deviation);
                        return true;
                }
 
                if (deviation < min)
                        min = deviation;
 
                        return true;
                }
 
                if (deviation < min)
                        min = deviation;
 
-               div++;
+               divider++;
        }
 
        LOG_ERROR("Selected trace frequency is not supported by the device. "
        }
 
        LOG_ERROR("Selected trace frequency is not supported by the device. "
@@ -1098,7 +1098,7 @@ static int config_trace(bool enabled, enum tpio_pin_protocol pin_protocol,
        int ret;
        uint32_t buffer_size;
        uint32_t freq;
        int ret;
        uint32_t buffer_size;
        uint32_t freq;
-       uint32_t div;
+       uint32_t divider;
 
        if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SWO)) {
                LOG_ERROR("Trace capturing is not supported by the device.");
 
        if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SWO)) {
                LOG_ERROR("Trace capturing is not supported by the device.");
@@ -1137,7 +1137,7 @@ static int config_trace(bool enabled, enum tpio_pin_protocol pin_protocol,
                return ERROR_FAIL;
        }
 
                return ERROR_FAIL;
        }
 
-       ret = jaylink_swo_get_speeds(devh, JAYLINK_SWO_MODE_UART, &freq, &div);
+       ret = jaylink_swo_get_speeds(devh, JAYLINK_SWO_MODE_UART, &freq, &divider);
 
        if (ret != JAYLINK_OK) {
                LOG_ERROR("jaylink_swo_get_speeds() failed: %s.",
 
        if (ret != JAYLINK_OK) {
                LOG_ERROR("jaylink_swo_get_speeds() failed: %s.",
@@ -1146,9 +1146,9 @@ static int config_trace(bool enabled, enum tpio_pin_protocol pin_protocol,
        }
 
        if (!*trace_freq)
        }
 
        if (!*trace_freq)
-               *trace_freq = freq / div;
+               *trace_freq = freq / divider;
 
 
-       if (!check_trace_freq(freq, div, *trace_freq))
+       if (!check_trace_freq(freq, divider, *trace_freq))
                return ERROR_FAIL;
 
        LOG_DEBUG("Using %u bytes device memory for trace capturing.", buffer_size);
                return ERROR_FAIL;
 
        LOG_DEBUG("Using %u bytes device memory for trace capturing.", buffer_size);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)