* [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro
@ 2016-10-16 13:30 sayli karnik
2016-10-17 7:34 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: sayli karnik @ 2016-10-16 13:30 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Greg Kroah-Hartman
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)
)
Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
---
Changes in v2:
Adjusted the changed part in one line
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 5ec7c96..7fee140 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -190,8 +190,7 @@ 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);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro
2016-10-16 13:30 [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro sayli karnik
@ 2016-10-17 7:34 ` Greg Kroah-Hartman
2016-10-17 15:12 ` sayli karnik
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-17 7:34 UTC (permalink / raw)
To: sayli karnik; +Cc: outreachy-kernel
On Sun, Oct 16, 2016 at 07:00:51PM +0530, sayli karnik wrote:
> 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)
> )
>
> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> ---
> Changes in v2:
> Adjusted the changed part in one line
>
> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index 5ec7c96..7fee140 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -190,8 +190,7 @@ 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));
How were you able to test build this change? The code is currently
broken in the build unless you add a number of external patches at the
moment :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro
2016-10-17 7:34 ` Greg Kroah-Hartman
@ 2016-10-17 15:12 ` sayli karnik
2016-10-17 16:19 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: sayli karnik @ 2016-10-17 15:12 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: outreachy-kernel
On Mon, Oct 17, 2016 at 1:04 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Sun, Oct 16, 2016 at 07:00:51PM +0530, sayli karnik wrote:
>> 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)
>> )
>>
>> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
>> ---
>> Changes in v2:
>> Adjusted the changed part in one line
>>
>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> index 5ec7c96..7fee140 100644
>> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> @@ -190,8 +190,7 @@ 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));
>
> How were you able to test build this change? The code is currently
> broken in the build unless you add a number of external patches at the
> moment :(
>
Yes it is broken.
Also there isn't a Makefile in
drivers/staging/vc04_services/interface/vchiq_arm/ to build it.
thanks,
sayli
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro
2016-10-17 15:12 ` sayli karnik
@ 2016-10-17 16:19 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-17 16:19 UTC (permalink / raw)
To: sayli karnik; +Cc: outreachy-kernel
On Mon, Oct 17, 2016 at 08:42:31PM +0530, sayli karnik wrote:
> On Mon, Oct 17, 2016 at 1:04 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Sun, Oct 16, 2016 at 07:00:51PM +0530, sayli karnik wrote:
> >> 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)
> >> )
> >>
> >> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> >> ---
> >> Changes in v2:
> >> Adjusted the changed part in one line
> >>
> >> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
> >> 1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> >> index 5ec7c96..7fee140 100644
> >> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> >> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> >> @@ -190,8 +190,7 @@ 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));
> >
> > How were you able to test build this change? The code is currently
> > broken in the build unless you add a number of external patches at the
> > moment :(
> >
> Yes it is broken.
> Also there isn't a Makefile in
> drivers/staging/vc04_services/interface/vchiq_arm/ to build it.
That's ok, the Makefile a few directories up from that is the one that
builds it.
I'm going to hold off applying this patch until you can test-build it.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-17 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-16 13:30 [PATCH v2] staging: vc04_services: vchiq_arm: Use ARRAY_SIZE macro sayli karnik
2016-10-17 7:34 ` Greg Kroah-Hartman
2016-10-17 15:12 ` sayli karnik
2016-10-17 16:19 ` Greg Kroah-Hartman
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.