perf tools: Use ARRAY_SIZE macro
Subsystems (5)
PATCH 1/6 perf tools: Use ARRAY_SIZE macro
Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- tools/perf/tests/bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/bpf.c +1 -1
@@ -309,7 +309,7 @@ static int check_env(void) } err =bpf_load_program (BPF_PROG_TYPE_KPROBE , insns, -sizeof (insns) /sizeof (insns[0 ]), +ARRAY_SIZE (insns), license, kver_int,NULL ,0 );if (err <0 ) { pr_err("Missing basic BPF support, skip this test: %s\n",
Signature · 1 line
2.11.0
PATCH 2/6 perf dwarf: Use ARRAY_SIZE macro
Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- tools/perf/arch/x86/util/dwarf-regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/x86/util/dwarf-regs.c +1 -1
@@ -103,7 +103,7 @@ static const struct pt_regs_offset x86_64_regoffset_table[] = {#endif /* Minus 1 for the ending REG_OFFSET_END */ -#define ARCH_MAX_REGS ((sizeof(regoffset_table) / sizeof(regoffset_table[0])) - 1) +#define ARCH_MAX_REGS (ARRAY_SIZE(regoffset_table) - 1)/* Return architecture dependent register string (for kprobe-tracer) */ const char *get_arch_regstr (unsigned int n)
Signature · 1 line
2.11.0
PATCH 3/6 ia64: Use ARRAY_SIZE macro
In reply to Thomas MeyerFound by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- arch/ia64/kernel/perfmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/perfmon.c +1 -1
@@ -4653,7 +4653,7 @@ static pfm_cmd_desc_t pfm_cmd_tab[]={/* 32 */ PFM_CMD (pfm_write_ibrs,PFM_CMD_PCLRWS ,PFM_CMD_ARG_MANY , pfarg_dbreg_t,NULL ), /* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL) }; -#define PFM_CMD_COUNT (sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t)) +#define PFM_CMD_COUNT ARRAY_SIZE(pfm_cmd_tab)static int pfm_check_task_state (pfm_context_t *ctx,int cmd,unsigned long flags)
Signature · 1 line
2.11.0
PATCH 4/6 skd: Use ARRAY_SIZE macro
In reply to Thomas MeyerFound by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- drivers/block/skd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/skd_main.c +1 -1
@@ -2275,7 +2275,7 @@ skd_check_status(struct skd_device *skdev, skerr->key, skerr->code, skerr->qual, skerr->fruc);/* Does the info match an entry in the good category? */ - n =sizeof (skd_chkstat_table) /sizeof (skd_chkstat_table[0 ]); + n =ARRAY_SIZE (skd_chkstat_table);for (i =0 ; i < n; i++) {struct sns_info *sns = &skd_chkstat_table[i];
Signature · 1 line
2.11.0
PATCH 5/6 powerpc/xmon: Use ARRAY_SIZE macro
In reply to Thomas MeyerFound by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- arch/powerpc/xmon/ppc-opc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
arch/powerpc/xmon/ppc-opc.c +6 -8
@@ -966,8 +966,7 @@ const struct powerpc_operand powerpc_operands[] = { 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT }, }; -const unsigned int num_powerpc_operands = (sizeof (powerpc_operands) - /sizeof (powerpc_operands[0 ])); +const unsigned int num_powerpc_operands =ARRAY_SIZE (powerpc_operands);/* The functions used to insert and extract complicated operands. */
@@ -6980,8 +6979,8 @@ const struct powerpc_opcode powerpc_opcodes[] = { {"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}}, }; -const int powerpc_num_opcodes = -sizeof (powerpc_opcodes) /sizeof (powerpc_opcodes[0 ]); +const int powerpc_num_opcodes =ARRAY_SIZE (powerpc_opcodes); +/* The VLE opcode table.
@@ -7219,8 +7218,8 @@ const struct powerpc_opcode vle_opcodes[] = { {"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}}, }; -const int vle_num_opcodes = -sizeof (vle_opcodes) /sizeof (vle_opcodes[0 ]); +const int vle_num_opcodes =ARRAY_SIZE (vle_opcodes); +/* The macro table. This is only used by the assembler. */
@@ -7288,5 +7287,4 @@ const struct powerpc_macro powerpc_macros[] = { {"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"}, }; -const int powerpc_num_macros = -sizeof (powerpc_macros) /sizeof (powerpc_macros[0 ]); +const int powerpc_num_macros =ARRAY_SIZE (powerpc_macros);
Signature · 1 line
2.11.0
PATCH 6/6 x86/platform/intel-mid: Use ARRAY_SIZE macro
In reply to Thomas MeyerFound by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci
--- arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c +1 -1
@@ -64,7 +64,7 @@ static int __init pb_keys_init(void)struct gpio_keys_button *gb = gpio_button;int i, num, good =0 ; - num =sizeof (gpio_button) /sizeof (struct gpio_keys_button ); + num =ARRAY_SIZE (gpio_button);for (i =0 ; i < num; i++) { gb[i].gpio =get_gpio_by_name (gb[i].desc); pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
Signature · 1 line
2.11.0