coding style: use ARRAY_SIZE() when possible 98/5198/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 6 May 2019 10:50:44 +0000 (12:50 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 15 Feb 2020 15:37:40 +0000 (15:37 +0000)
We have the macro ARRAY_SIZE() already available. Use it!

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types ARRAY_SIZE -f {} \;

Change-Id: Ic7da9b710edf118eacb08f9e222f34208c580842
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5198
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/flash/nor/ambiqmicro.c
src/flash/nor/numicro.c
src/flash/nor/psoc6.c
src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c

index b1e3e72a958d945d2d1048c954961f5a8f4f2be1..b41b15c075865153eda89768f49a66f002555da8 100644 (file)
@@ -253,8 +253,7 @@ static int ambiqmicro_read_part_info(struct flash_bank *bank)
 
        }
 
-       if (ambiqmicro_info->target_class <
-               (sizeof(ambiqmicroParts)/sizeof(ambiqmicroParts[0])))
+       if (ambiqmicro_info->target_class < ARRAY_SIZE(ambiqmicroParts))
                ambiqmicro_info->target_name =
                        ambiqmicroParts[ambiqmicro_info->target_class].partname;
        else
index c62af04bf28908861bb8cad1dba5dfdc248775f5..9e18136fad19a55fc884c0d8c37ce698f76fc35d 100644 (file)
@@ -1663,7 +1663,7 @@ static int numicro_get_cpu_type(struct target *target, const struct numicro_cpu_
 
        LOG_INFO("Device ID: 0x%08" PRIx32 "", part_id);
        /* search part numbers */
-       for (size_t i = 0; i < sizeof(NuMicroParts)/sizeof(NuMicroParts[0]); i++) {
+       for (size_t i = 0; i < ARRAY_SIZE(NuMicroParts); i++) {
                if (part_id == NuMicroParts[i].partid) {
                        *cpu = &NuMicroParts[i];
                        LOG_INFO("Device Name: %s", (*cpu)->partname);
index 386075e2c3a79eef08d3b0c047fef9f72d5533d3..3cdfcc4241ed15351fd81c8b06a8562021e02d19 100644 (file)
@@ -108,7 +108,7 @@ static const struct row_region safe_sflash_regions[] = {
        {0x16007C00, 0x400},    /* SFLASH: TOC2 */
 };
 
-#define SFLASH_NUM_REGIONS (sizeof(safe_sflash_regions) / sizeof(safe_sflash_regions[0]))
+#define SFLASH_NUM_REGIONS ARRAY_SIZE(safe_sflash_regions)
 
 static struct working_area *g_stack_area;
 static struct armv7m_algorithm g_armv7m_info;
index 53a7e989b333db29befd7f2357407815f96752d7..678b097c94c8706314b4b765a86a7a3c0c3cfb93 100644 (file)
@@ -48,7 +48,7 @@ uint8_t usbtoxxx_abilities[USB_TO_XXX_ABILITIES_LEN];
 
 #define usbtoxxx_get_type_name(type)   \
        types_name[((type) - VERSALOON_USB_TO_XXX_CMD_START) \
-                  % (sizeof(types_name) / sizeof(types_name[0]))]
+                  % ARRAY_SIZE(types_name)]
 
 static uint8_t type_pre;
 static uint16_t usbtoxxx_buffer_index;

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)