* [PATCH 0/2] Use ARRAY_SIZE macro
@ 2015-10-07 12:49 Shraddha Barke
2015-10-07 12:49 ` [PATCH 1/2] Staging: sm750fb: " Shraddha Barke
2015-10-07 12:49 ` [PATCH 2/2] Staging: speakup: " Shraddha Barke
0 siblings, 2 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-07 12:49 UTC (permalink / raw)
To: outreachy-kernel
Used ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0])
Coccinelle is used to make the changes-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
Shraddha Barke (2):
Staging: sm750fb: Use ARRAY_SIZE macro
Staging: speakup: Use ARRAY_SIZE macro
drivers/staging/sm750fb/ddk750_chip.c | 4 ++--
drivers/staging/speakup/i18n.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Staging: sm750fb: Use ARRAY_SIZE macro
2015-10-07 12:49 [PATCH 0/2] Use ARRAY_SIZE macro Shraddha Barke
@ 2015-10-07 12:49 ` Shraddha Barke
2015-10-08 7:05 ` [Outreachy kernel] " Julia Lawall
2015-10-08 8:49 ` Greg KH
2015-10-07 12:49 ` [PATCH 2/2] Staging: speakup: " Shraddha Barke
1 sibling, 2 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-07 12:49 UTC (permalink / raw)
To: outreachy-kernel
ARRAY_SIZE is more concise to use when the size of an array is divided
by the size of its type or the size of its first element.
Change made using Coccinelle-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/sm750fb/ddk750_chip.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index e987971..f542cd5 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -391,10 +391,10 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
if (pll->clockType != MXCLK_PLL) {
xparm = &xparm_PIXEL[0];
- xcnt = sizeof(xparm_PIXEL)/sizeof(xparm_PIXEL[0]);
+ xcnt = ARRAY_SIZE(xparm_PIXEL);
} else {
xparm = &xparm_MXCLK[0];
- xcnt = sizeof(xparm_MXCLK)/sizeof(xparm_MXCLK[0]);
+ xcnt = ARRAY_SIZE(xparm_MXCLK);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Staging: speakup: Use ARRAY_SIZE macro
2015-10-07 12:49 [PATCH 0/2] Use ARRAY_SIZE macro Shraddha Barke
2015-10-07 12:49 ` [PATCH 1/2] Staging: sm750fb: " Shraddha Barke
@ 2015-10-07 12:49 ` Shraddha Barke
1 sibling, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-07 12:49 UTC (permalink / raw)
To: outreachy-kernel
ARRAY_SIZE is more concise to use when the size of an array is divided
by the size of its type or the size of its first element.
Changes made using Coccinelle-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/speakup/i18n.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
index f061747..12f880e 100644
--- a/drivers/staging/speakup/i18n.c
+++ b/drivers/staging/speakup/i18n.c
@@ -389,7 +389,7 @@ static struct msg_group_t all_groups[] = {
},
};
-static const int num_groups = sizeof(all_groups) / sizeof(struct msg_group_t);
+static const int num_groups = ARRAY_SIZE(all_groups);
char *spk_msg_get(enum msg_index_t index)
{
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: sm750fb: Use ARRAY_SIZE macro
2015-10-07 12:49 ` [PATCH 1/2] Staging: sm750fb: " Shraddha Barke
@ 2015-10-08 7:05 ` Julia Lawall
2015-10-08 8:49 ` Greg KH
1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-10-08 7:05 UTC (permalink / raw)
To: Shraddha Barke; +Cc: outreachy-kernel
On Wed, 7 Oct 2015, Shraddha Barke wrote:
> ARRAY_SIZE is more concise to use when the size of an array is divided
> by the size of its type or the size of its first element.
>
> Change made using Coccinelle-
>
> @@
> type T;
> T[] E;
> @@
>
> - (sizeof(E)/sizeof(T))
> + ARRAY_SIZE(E)
This semantic patch doesn't have a pattern for the size of the first
element. You don't have to put the complete semantic patch in the commit
message whn it does multiple things. But it would be better to put the
part of the semantic patch that actually relates to the transformation
that is made. Then someone can understand the transformation that was
made better.
julia
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> drivers/staging/sm750fb/ddk750_chip.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
> index e987971..f542cd5 100644
> --- a/drivers/staging/sm750fb/ddk750_chip.c
> +++ b/drivers/staging/sm750fb/ddk750_chip.c
> @@ -391,10 +391,10 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
>
> if (pll->clockType != MXCLK_PLL) {
> xparm = &xparm_PIXEL[0];
> - xcnt = sizeof(xparm_PIXEL)/sizeof(xparm_PIXEL[0]);
> + xcnt = ARRAY_SIZE(xparm_PIXEL);
> } else {
> xparm = &xparm_MXCLK[0];
> - xcnt = sizeof(xparm_MXCLK)/sizeof(xparm_MXCLK[0]);
> + xcnt = ARRAY_SIZE(xparm_MXCLK);
> }
>
>
> --
> 2.1.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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1444222177-11153-2-git-send-email-shraddha.6596%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: sm750fb: Use ARRAY_SIZE macro
2015-10-07 12:49 ` [PATCH 1/2] Staging: sm750fb: " Shraddha Barke
2015-10-08 7:05 ` [Outreachy kernel] " Julia Lawall
@ 2015-10-08 8:49 ` Greg KH
2015-10-08 10:48 ` Shraddha Barke
1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2015-10-08 8:49 UTC (permalink / raw)
To: Shraddha Barke; +Cc: outreachy-kernel
On Wed, Oct 07, 2015 at 06:19:36PM +0530, Shraddha Barke wrote:
> ARRAY_SIZE is more concise to use when the size of an array is divided
> by the size of its type or the size of its first element.
>
> Change made using Coccinelle-
>
> @@
> type T;
> T[] E;
> @@
>
> - (sizeof(E)/sizeof(T))
> + ARRAY_SIZE(E)
>
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> drivers/staging/sm750fb/ddk750_chip.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Doesn't apply to my tree :(
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: sm750fb: Use ARRAY_SIZE macro
2015-10-08 8:49 ` Greg KH
@ 2015-10-08 10:48 ` Shraddha Barke
0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-08 10:48 UTC (permalink / raw)
To: Greg KH; +Cc: outreachy-kernel
On Thu, 8 Oct 2015, Greg KH wrote:
> On Wed, Oct 07, 2015 at 06:19:36PM +0530, Shraddha Barke wrote:
>> ARRAY_SIZE is more concise to use when the size of an array is divided
>> by the size of its type or the size of its first element.
>>
>> Change made using Coccinelle-
>>
>> @@
>> type T;
>> T[] E;
>> @@
>>
>> - (sizeof(E)/sizeof(T))
>> + ARRAY_SIZE(E)
>>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
>> drivers/staging/sm750fb/ddk750_chip.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Doesn't apply to my tree :(
Umm, it applied when I tried it. A change was made recently to this file
https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing&id=31418e37019ec188f4201587c7234bfb463e7bf4
before this patch was applied. Do you think it's because of that?. I'm
trying to understand how this works.
Anyways, I'll resend it with suggestions made by Julia.
Thanks,
Shraddha
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-08 10:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 12:49 [PATCH 0/2] Use ARRAY_SIZE macro Shraddha Barke
2015-10-07 12:49 ` [PATCH 1/2] Staging: sm750fb: " Shraddha Barke
2015-10-08 7:05 ` [Outreachy kernel] " Julia Lawall
2015-10-08 8:49 ` Greg KH
2015-10-08 10:48 ` Shraddha Barke
2015-10-07 12:49 ` [PATCH 2/2] Staging: speakup: " Shraddha Barke
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.