Skip to contentSkip to conversation

perfmon: use ARRAY_SIZE() macro

PATCH In review Gustavo A. R. Silva 1 participant 2 messages Dec 25, 2018 – Jan 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perfmon: use ARRAY_SIZE() macro

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element or, as in this particular case, sizeof the structure name.

This issue was detected with the help of Coccinelle.

---
 arch/ia64/kernel/perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/perfmon.c +1 -1
index 46bff1661836..b39df5078e19 100644
@@ -4644,7 +4644,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.20.1
#1 lore raw

Hi,

Friendly ping:

Who can take this, please?

Thanks
--
Gustavo

Quoted 24 lines · Gustavo A. R. Silva

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element or, as in this particular case, sizeof the structure name.

This issue was detected with the help of Coccinelle.

---
  arch/ia64/kernel/perfmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/perfmon.c +1 -1
index 46bff1661836..b39df5078e19 100644
@@ -4644,7 +4644,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)