Skip to contentSkip to conversation

drivers:platform/x86:Use ARRAY_SIZE() for the size calculation of the array.

PATCH Superseded Allen Pais 3 participants 4 messages Sep 13, 2017 x86 platform drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Allen Pais

author
#0 lore raw

PATCH v2 1/1 drivers:platform/x86:Use ARRAY_SIZE() for the size calculation of the array.

---
 drivers/platform/x86/intel_telemetry_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_telemetry_debugfs.c +1 -1
index d4fc42b..6b63b3d 100644
@@ -76,7 +76,7 @@
 #define TELEM_IOSS_DX_D0IX_EVTS		25
 #define TELEM_IOSS_PG_EVTS		30
 
-#define TELEM_EVT_LEN(x) (sizeof(x)/sizeof((x)[0]))
+#define TELEM_EVT_LEN(x) ARRAY_SIZE(x)
 
 #define TELEM_DEBUGFS_CPU(model, data) \
 	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&data}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 10 lines · Allen Pais
---
 drivers/platform/x86/intel_telemetry_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_telemetry_debugfs.c +0 -0
index d4fc42b..6b63b3d 100644

drivers/platform/x86/intel_telemetry_debugfs.c line 82

Quoted 8 lines
drivers/platform/x86/intel_telemetry_debugfs.c +1 -1
@@ -76,7 +76,7 @@
 #define TELEM_IOSS_DX_D0IX_EVTS		25
 #define TELEM_IOSS_PG_EVTS		30
 
-#define TELEM_EVT_LEN(x) (sizeof(x)/sizeof((x)[0]))
+#define TELEM_EVT_LEN(x) ARRAY_SIZE(x)
 
 #define TELEM_DEBUGFS_CPU(model, data) \
 	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&data}

What's the point? Why not simply replace all instances of TELEM_EVT_LEN with ARRAY_SIZE?

Bjørn

#2 lore raw
Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:platform-driver- [email protected]] On Behalf Of Bjørn Mork
Sent: Wednesday, September 13, 2017 3:32 PM
To: Allen Pais <[email protected]>
Cc: [email protected]; Chakravarty, Souvik K <[email protected]>; [email protected]
Subject: Re: [PATCH v2] drivers:platform/x86:Use ARRAY_SIZE() for the size calculation of the array.

Quoted 17 lines · Allen Pais
---
 drivers/platform/x86/intel_telemetry_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_telemetry_debugfs.c +1 -1
index d4fc42b..6b63b3d 100644
@@ -76,7 +76,7 @@
 #define TELEM_IOSS_DX_D0IX_EVTS		25
 #define TELEM_IOSS_PG_EVTS		30
 
-#define TELEM_EVT_LEN(x) (sizeof(x)/sizeof((x)[0]))
+#define TELEM_EVT_LEN(x) ARRAY_SIZE(x)
 
Quoted 6 lines

drivers/platform/x86/intel_telemetry_debugfs.c line 82

Quoted 2 lines
drivers/platform/x86/intel_telemetry_debugfs.c +0 -0
 #define TELEM_DEBUGFS_CPU(model, data) \
 	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned

long)&data}

What's the point? Why not simply replace all instances of TELEM_EVT_LEN with ARRAY_SIZE?

I was about to say this too, although I should have probably said this in the first spin itself.

Quoted 4 lines

Bjørn

author
#3 lore raw
Quoted 5 lines
Quoted 3 lines

What's the point? Why not simply replace all instances of TELEM_EVT_LEN with ARRAY_SIZE?

I was about to say this too, although I should have probably said this in the first spin itself.

I'll have it done and send out v3.

- Allen