Skip to contentSkip to conversation

staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro

PATCH Superseded sayli karnik 2 participants 3 messages Oct 16, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro

This patch uses ARRAY_SIZE macro instead of division of two sizeofs to find array size. Done using coccinelle.
@@
type T;
T[] E;
@@
(
- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
)

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
index 5ec7c96..f7d9513 100644
@@ -190,8 +190,8 @@ static const char *const ioctl_names[] = {
 	"CLOSE_DELIVERED"
 };
 
-vchiq_static_assert((sizeof(ioctl_names)/sizeof(ioctl_names[0])) ==
-	(VCHIQ_IOC_MAX + 1));
+vchiq_static_assert(ARRAY_SIZE(ioctl_names) ==
+		    (VCHIQ_IOC_MAX + 1));
 
 static void
 dump_phys_mem(void *virt_addr, uint32_t num_bytes);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 27 lines · sayli karnik

This patch uses ARRAY_SIZE macro instead of division of two sizeofs to find array size. Done using coccinelle.
@@
type T;
T[] E;
@@
(
- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
)

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0 -0
index 5ec7c96..f7d9513 100644

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c static const char *const ioctl_names[] = { · line 194

Quoted 7 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
@@ -190,8 +190,8 @@ static const char *const ioctl_names[] = {
 	"CLOSE_DELIVERED"
 };
 
-vchiq_static_assert((sizeof(ioctl_names)/sizeof(ioctl_names[0])) ==
-	(VCHIQ_IOC_MAX + 1));
+vchiq_static_assert(ARRAY_SIZE(ioctl_names) ==
+		    (VCHIQ_IOC_MAX + 1));

Doesn't this code all fit on one line?

julia

Quoted 13 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0 -1
 static void
 dump_phys_mem(void *virt_addr, uint32_t num_bytes);
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20161016071531.GA15510%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 34 lines · Julia Lawall
Quoted 30 lines · sayli karnik

This patch uses ARRAY_SIZE macro instead of division of two sizeofs to find array size. Done using coccinelle.
@@
type T;
T[] E;
@@
(
- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
)

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0 -0
index 5ec7c96..f7d9513 100644
@@ -190,8 +190,8 @@ static const char *const ioctl_names[] = {
      "CLOSE_DELIVERED"
 };
 
Quoted 7 lines

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c static const char *const ioctl_names[] = { · line 194

Quoted 4 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
-vchiq_static_assert((sizeof(ioctl_names)/sizeof(ioctl_names[0])) ==
-     (VCHIQ_IOC_MAX + 1));
+vchiq_static_assert(ARRAY_SIZE(ioctl_names) ==
+                 (VCHIQ_IOC_MAX + 1));

Doesn't this code all fit on one line?

yes it does.

thanks,
sayli

Quoted 15 lines

julia

Quoted 13 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0 -1
 static void
 dump_phys_mem(void *virt_addr, uint32_t num_bytes);
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20161016071531.GA15510%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.