coding style: add parenthesis around the argument of sizeof

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
This commit is contained in:
Antonio Borneo 2019-05-06 00:35:52 +02:00
parent 9b29cb58ac
commit e66bb9d312
15 changed files with 32 additions and 32 deletions

View 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;

View 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] = '*';

View 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;

View 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;

View 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;

View 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]);

View 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;

View 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] = '*';

View 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;

View 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;

View 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) {

View 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);

View 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);

View 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;

View 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;
}