All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] perf tools: Use ARRAY_SIZE macro
@ 2017-09-01 21:29 Thomas Meyer
  2017-09-01 21:29 ` [PATCH 2/6] perf dwarf: " Thomas Meyer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 tools/perf/tests/bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 5876da126b58..4e7b5b63ac28 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -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",
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] perf dwarf: Use ARRAY_SIZE macro
  2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
@ 2017-09-01 21:29 ` Thomas Meyer
  2017-09-01 21:29 ` [PATCH 3/6] ia64: " Thomas Meyer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 tools/perf/arch/x86/util/dwarf-regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c
index 1f86ee8fb831..d9d4626b0fa9 100644
--- a/tools/perf/arch/x86/util/dwarf-regs.c
+++ b/tools/perf/arch/x86/util/dwarf-regs.c
@@ -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)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] ia64: Use ARRAY_SIZE macro
  2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
  2017-09-01 21:29 ` [PATCH 2/6] perf dwarf: " Thomas Meyer
@ 2017-09-01 21:29 ` Thomas Meyer
  2017-09-01 21:29 ` [PATCH 4/6] skd: " Thomas Meyer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/ia64/kernel/perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 09f86ebfcc7b..f1be357a4288 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -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)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] skd: Use ARRAY_SIZE macro
  2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
  2017-09-01 21:29 ` [PATCH 2/6] perf dwarf: " Thomas Meyer
  2017-09-01 21:29 ` [PATCH 3/6] ia64: " Thomas Meyer
@ 2017-09-01 21:29 ` Thomas Meyer
  2017-09-01 21:29 ` [PATCH 5/6] powerpc/xmon: " Thomas Meyer
  2017-09-01 21:29 ` [PATCH 6/6] x86/platform/intel-mid: " Thomas Meyer
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 drivers/block/skd_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index d0368682bd43..623bc92bde5c 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -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];
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] powerpc/xmon: Use ARRAY_SIZE macro
  2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
                   ` (2 preceding siblings ...)
  2017-09-01 21:29 ` [PATCH 4/6] skd: " Thomas Meyer
@ 2017-09-01 21:29 ` Thomas Meyer
  2017-09-01 21:29 ` [PATCH 6/6] x86/platform/intel-mid: " Thomas Meyer
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/powerpc/xmon/ppc-opc.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index ac2b55b1332e..35c23517d523 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -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);
+
 \f
 /* 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);
+
 \f
 /* 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);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] x86/platform/intel-mid: Use ARRAY_SIZE macro
  2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
                   ` (3 preceding siblings ...)
  2017-09-01 21:29 ` [PATCH 5/6] powerpc/xmon: " Thomas Meyer
@ 2017-09-01 21:29 ` Thomas Meyer
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2017-09-01 21:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Meyer

Found by a coccinelle run with:
make coccicheck MODE=patch COCCI=scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
index 74283875c7e8..8e2fbd35a9e6 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
@@ -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,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-01 21:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 21:29 [PATCH 1/6] perf tools: Use ARRAY_SIZE macro Thomas Meyer
2017-09-01 21:29 ` [PATCH 2/6] perf dwarf: " Thomas Meyer
2017-09-01 21:29 ` [PATCH 3/6] ia64: " Thomas Meyer
2017-09-01 21:29 ` [PATCH 4/6] skd: " Thomas Meyer
2017-09-01 21:29 ` [PATCH 5/6] powerpc/xmon: " Thomas Meyer
2017-09-01 21:29 ` [PATCH 6/6] x86/platform/intel-mid: " Thomas Meyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.