coding style: add parenthesis around the argument of sizeof 18/5618/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 5 May 2019 22:35:52 +0000 (00:35 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 9 May 2020 13:39:19 +0000 (14:39 +0100)
The script checkpatch available in new Linux kernel offers an
experimental feature for automatically fix the code in place.
While still experimental, the feature works quite well for simple
fixes, like parenthesis.

This patch has been created automatically with the script under
review for inclusion in OpenOCD, using the command:

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

Change-Id: I8adb325bdb0e13211f8bae8b4770ec1979c176bf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5618
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
15 files changed:
src/flash/nand/davinci.c
src/jtag/aice/aice_transport.c
src/jtag/core.c
src/jtag/drivers/amt_jtagaccel.c
src/jtag/drivers/gw16012.c
src/jtag/drivers/kitprog.c
src/jtag/drivers/parport.c
src/jtag/tcl.c
src/target/arm11.c
src/target/arm11_dbgtap.c
src/target/arm_disassembler.c
src/target/arm_dpm.c
src/target/armv8_dpm.c
src/target/cortex_m.c
src/target/xscale.c

index 17e6f680da4dc7f7442e92bb6ea8092c64471a85..167b40150406c97c118a8b18255d4a71f4ccd3e3 100644 (file)
@@ -730,7 +730,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
                goto fail;
        }
 
-       info = calloc(1, sizeof *info);
+       info = calloc(1, sizeof(*info));
        if (info == NULL)
                goto fail;
 
index d0f7a49c085c72eb23e6f8ebc788e525c62e49a7..ea710ad25d24da45748e394c6239c12e41377193 100644 (file)
@@ -174,7 +174,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
        while (tap) {
                uint32_t expected, expected_mask, ii;
 
-               snprintf(expected_id, sizeof expected_id, "0x%08x",
+               snprintf(expected_id, sizeof(expected_id), "0x%08x",
                        (unsigned)((tap->expected_ids_cnt > 0)
                                   ? tap->expected_ids[0]
                                   : 0));
@@ -196,7 +196,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
                        (unsigned int)(expected_mask));
 
                for (ii = 1; ii < tap->expected_ids_cnt; ii++) {
-                       snprintf(expected_id, sizeof expected_id, "0x%08x",
+                       snprintf(expected_id, sizeof(expected_id), "0x%08x",
                                (unsigned) tap->expected_ids[ii]);
                        if (tap->ignore_version)
                                expected_id[2] = '*';
index 2d0c84205e934866d347c83f68ad8408422e0f46..f12ab592495b996b0590bfb1ee7829da4c10922d 100644 (file)
@@ -1269,7 +1269,7 @@ static int jtag_examine_chain(void)
                         * REVISIT create a jtag_alloc(chip, tap) routine, and
                         * share it with jim_newtap_cmd().
                         */
-                       tap = calloc(1, sizeof *tap);
+                       tap = calloc(1, sizeof(*tap));
                        if (!tap) {
                                retval = ERROR_FAIL;
                                goto out;
index db106bb052a5bf1edbaab61d5dea483eef334e5d..f5918a0555127d17caa1eaa8788383acfab18903 100644 (file)
@@ -393,7 +393,7 @@ int amt_jtagaccel_get_giveio_access(void)
        HANDLE h;
        OSVERSIONINFO version;
 
-       version.dwOSVersionInfoSize = sizeof version;
+       version.dwOSVersionInfoSize = sizeof(version);
        if (!GetVersionEx(&version)) {
                errno = EINVAL;
                return -1;
index 2e8dad89608e36ac2015d3b75c66372b0f04f6db..d1699ef01aa302c6920fe642d626f55bd4086c58 100644 (file)
@@ -350,7 +350,7 @@ static int gw16012_get_giveio_access(void)
        HANDLE h;
        OSVERSIONINFO version;
 
-       version.dwOSVersionInfoSize = sizeof version;
+       version.dwOSVersionInfoSize = sizeof(version);
        if (!GetVersionEx(&version)) {
                errno = EINVAL;
                return -1;
index 28ed7ac619548204a55ab2a5d9be414a42a1ea2d..efb8da2cd20968d0ed3196dc9fe9a7a6200aa8c7 100644 (file)
@@ -358,7 +358,7 @@ static int kitprog_get_version(void)
        unsigned char command[3] = {HID_TYPE_START | HID_TYPE_WRITE, 0x00, HID_COMMAND_VERSION};
        unsigned char data[64];
 
-       ret = kitprog_hid_command(command, sizeof command, data, sizeof data);
+       ret = kitprog_hid_command(command, sizeof(command), data, sizeof(data));
        if (ret != ERROR_OK)
                return ret;
 
@@ -376,7 +376,7 @@ static int kitprog_get_millivolts(void)
        unsigned char command[3] = {HID_TYPE_START | HID_TYPE_READ, 0x00, HID_COMMAND_POWER};
        unsigned char data[64];
 
-       ret = kitprog_hid_command(command, sizeof command, data, sizeof data);
+       ret = kitprog_hid_command(command, sizeof(command), data, sizeof(data));
        if (ret != ERROR_OK)
                return ret;
 
@@ -603,7 +603,7 @@ static int kitprog_generic_acquire(void)
         * will take the Cortex-M3 out of reset and enable debugging.
         */
        for (int i = 0; i < 2; i++) {
-               for (uint8_t j = 0; j < sizeof devices && acquire_count == i; j++) {
+               for (uint8_t j = 0; j < sizeof(devices) && acquire_count == i; j++) {
                        retval = kitprog_acquire_psoc(devices[j], ACQUIRE_MODE_RESET, 3);
                        if (retval != ERROR_OK) {
                                LOG_DEBUG("Aquisition function failed for device 0x%02x.", devices[j]);
index 6d15203ae6e6973bcaefc6314ba937beb55c6448..b3abd120567e974c05248396992d05382675bca8 100644 (file)
@@ -237,7 +237,7 @@ static int parport_get_giveio_access(void)
        HANDLE h;
        OSVERSIONINFO version;
 
-       version.dwOSVersionInfoSize = sizeof version;
+       version.dwOSVersionInfoSize = sizeof(version);
        if (!GetVersionEx(&version)) {
                errno = EINVAL;
                return -1;
index 734b9c1cbd4c75f71fde13e257ee4a6edb87687d..f52cbd60623b46016904d7f6cf614ba254bd809a 100644 (file)
@@ -965,7 +965,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
        while (tap) {
                uint32_t expected, expected_mask, ii;
 
-               snprintf(expected_id, sizeof expected_id, "0x%08x",
+               snprintf(expected_id, sizeof(expected_id), "0x%08x",
                        (unsigned)((tap->expected_ids_cnt > 0)
                                   ? tap->expected_ids[0]
                                   : 0));
@@ -987,7 +987,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
                        (unsigned int)(expected_mask));
 
                for (ii = 1; ii < tap->expected_ids_cnt; ii++) {
-                       snprintf(expected_id, sizeof expected_id, "0x%08x",
+                       snprintf(expected_id, sizeof(expected_id), "0x%08x",
                                (unsigned) tap->expected_ids[ii]);
                        if (tap->ignore_version)
                                expected_id[2] = '*';
index 51f2a337ad4f5198d2658dab69dda09e0b4a9d82..10a1d6de5298a0e8259233092357910fb6da3c83 100644 (file)
@@ -1105,7 +1105,7 @@ static int arm11_target_create(struct target *target, Jim_Interp *interp)
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       arm11 = calloc(1, sizeof *arm11);
+       arm11 = calloc(1, sizeof(*arm11));
        if (!arm11)
                return ERROR_FAIL;
 
index 2232b3ef6df99c384b6d65f2a716f7dc73adb1e6..a758db58fc09836dcf628c7db2e63cb56f6ccf39 100644 (file)
@@ -1183,7 +1183,7 @@ int arm11_dpm_init(struct arm11_common *arm11, uint32_t didr)
 
        /* alloc enough to enable all breakpoints and watchpoints at once */
        arm11->bpwp_actions = calloc(2 * (dpm->nbp + dpm->nwp),
-                       sizeof *arm11->bpwp_actions);
+                       sizeof(*arm11->bpwp_actions));
        if (!arm11->bpwp_actions)
                return ERROR_FAIL;
 
index 04c3922963c3d1b4d420e0122642b856735a0075..55aaddd0a6f7fbb41085249d34074ae8e72c5987 100644 (file)
@@ -2672,7 +2672,7 @@ static int evaluate_load_store_multiple_thumb(uint16_t opcode,
                        instruction->type = ARM_STM;
                        mnemonic = "STM";
                }
-               snprintf(ptr_name, sizeof ptr_name, "r%i%s, ", Rn, wback);
+               snprintf(ptr_name, sizeof(ptr_name), "r%i%s, ", Rn, wback);
        } else {/* push/pop */
                Rn = 13;/* SP */
                if (L) {
index a01339c1f9bf7708cd9c6582fe08628cd9e1141a..495d63ec2829341fd44ed1955f30bf199b147e44 100644 (file)
@@ -1096,8 +1096,8 @@ int arm_dpm_setup(struct arm_dpm *dpm)
 
        dpm->nbp = 1 + ((dpm->didr >> 24) & 0xf);
        dpm->nwp = 1 + ((dpm->didr >> 28) & 0xf);
-       dpm->dbp = calloc(dpm->nbp, sizeof *dpm->dbp);
-       dpm->dwp = calloc(dpm->nwp, sizeof *dpm->dwp);
+       dpm->dbp = calloc(dpm->nbp, sizeof(*dpm->dbp));
+       dpm->dwp = calloc(dpm->nwp, sizeof(*dpm->dwp));
 
        if (!dpm->dbp || !dpm->dwp) {
                free(dpm->dbp);
index 5be52726c3d18ccaa2a2df858b7f4789eb900cdb..a3edb7f4752cd265dd01f63b1fbd6ea5a06c3ccb 100644 (file)
@@ -1471,10 +1471,10 @@ int armv8_dpm_setup(struct arm_dpm *dpm)
        /* FIXME add vector catch support */
 
        dpm->nbp = 1 + ((dpm->didr >> 12) & 0xf);
-       dpm->dbp = calloc(dpm->nbp, sizeof *dpm->dbp);
+       dpm->dbp = calloc(dpm->nbp, sizeof(*dpm->dbp));
 
        dpm->nwp = 1 + ((dpm->didr >> 20) & 0xf);
-       dpm->dwp = calloc(dpm->nwp, sizeof *dpm->dwp);
+       dpm->dwp = calloc(dpm->nwp, sizeof(*dpm->dwp));
 
        if (!dpm->dbp || !dpm->dwp) {
                free(dpm->dbp);
index af245dfc0bf43f174acc920697ecb7f90c5828c6..27febd3d779adf83dceae2f85b4d8553975a841d 100644 (file)
@@ -1980,7 +1980,7 @@ static void cortex_m_dwt_addreg(struct target *t, struct reg *r, const struct dw
 {
        struct dwt_reg_state *state;
 
-       state = calloc(1, sizeof *state);
+       state = calloc(1, sizeof(*state));
        if (!state)
                return;
        state->addr = d->addr;
@@ -2021,7 +2021,7 @@ fail0:
                return;
        }
 
-       cache = calloc(1, sizeof *cache);
+       cache = calloc(1, sizeof(*cache));
        if (!cache) {
 fail1:
                free(cm->dwt_comparator_list);
@@ -2029,7 +2029,7 @@ fail1:
        }
        cache->name = "Cortex-M DWT registers";
        cache->num_regs = 2 + cm->dwt_num_comp * 3;
-       cache->reg_list = calloc(cache->num_regs, sizeof *cache->reg_list);
+       cache->reg_list = calloc(cache->num_regs, sizeof(*cache->reg_list));
        if (!cache->reg_list) {
                free(cache);
                goto fail1;
index f879a9cc918f2c5d88470aa8406fb5579bd87f00..edab4f9fc72bb50e7c54560b15a43d1e9c13594b 100644 (file)
@@ -156,7 +156,7 @@ static int xscale_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_s
                struct scan_field field;
                uint8_t scratch[4] = { 0 };
 
-               memset(&field, 0, sizeof field);
+               memset(&field, 0, sizeof(field));
                field.num_bits = tap->ir_length;
                field.out_value = scratch;
                buf_set_u32(scratch, 0, field.num_bits, new_instr);
@@ -186,7 +186,7 @@ static int xscale_read_dcsr(struct target *target)
        buf_set_u32(&field0, 1, 1, xscale->hold_rst);
        buf_set_u32(&field0, 2, 1, xscale->external_debug_break);
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 3;
        fields[0].out_value = &field0;
@@ -259,7 +259,7 @@ static int xscale_receive(struct target *target, uint32_t *buffer, int num_words
        path[1] = TAP_DRCAPTURE;
        path[2] = TAP_DRSHIFT;
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 3;
        uint8_t tmp;
@@ -367,7 +367,7 @@ static int xscale_read_tx(struct target *target, int consume)
        noconsume_path[4] = TAP_DREXIT2;
        noconsume_path[5] = TAP_DRSHIFT;
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 3;
        fields[0].in_value = &field0_in;
@@ -442,7 +442,7 @@ static int xscale_write_rx(struct target *target)
                XSCALE_DBGRX << xscale->xscale_variant,
                TAP_IDLE);
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 3;
        fields[0].out_value = &field0_out;
@@ -598,7 +598,7 @@ static int xscale_write_dcsr(struct target *target, int hold_rst, int ext_dbg_br
        buf_set_u32(&field0, 1, 1, xscale->hold_rst);
        buf_set_u32(&field0, 2, 1, xscale->external_debug_break);
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 3;
        fields[0].out_value = &field0;
@@ -666,7 +666,7 @@ static int xscale_load_ic(struct target *target, uint32_t va, uint32_t buffer[8]
        /* virtual address of desired cache line */
        buf_set_u32(packet, 0, 27, va >> 5);
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 6;
        fields[0].out_value = &cmd;
@@ -713,7 +713,7 @@ static int xscale_invalidate_ic_line(struct target *target, uint32_t va)
        /* virtual address of desired cache line */
        buf_set_u32(packet, 0, 27, va >> 5);
 
-       memset(&fields, 0, sizeof fields);
+       memset(&fields, 0, sizeof(fields));
 
        fields[0].num_bits = 6;
        fields[0].out_value = &cmd;
@@ -1551,7 +1551,7 @@ static int xscale_deassert_reset(struct target *target)
                 * coprocessors, trace data, etc.
                 */
                address = xscale->handler_address;
-               for (unsigned binary_size = sizeof xscale_debug_handler;
+               for (unsigned binary_size = sizeof(xscale_debug_handler);
                        binary_size > 0;
                        binary_size -= buf_cnt, buffer += buf_cnt) {
                        uint32_t cache_line[8];
@@ -3004,7 +3004,7 @@ static int xscale_target_create(struct target *target, Jim_Interp *interp)
 {
        struct xscale_common *xscale;
 
-       if (sizeof xscale_debug_handler > 0x800) {
+       if (sizeof(xscale_debug_handler) > 0x800) {
                LOG_ERROR("debug_handler.bin: larger than 2kb");
                return ERROR_FAIL;
        }

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)