From: Deepak R Varma <drv@mailo.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
outreachy@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count
Date: Mon, 31 Oct 2022 15:11:36 +0530 [thread overview]
Message-ID: <Y1+YUMCog7K5fVep@ubunlion> (raw)
In-Reply-To: <Y1+YC5OuycA5hLFx@ubunlion>
[-- Attachment #1: Type: text/plain, Size: 3238 bytes --]
On Mon, Oct 31, 2022 at 03:10:27PM +0530, Deepak Varma wrote:
> On Mon, Oct 31, 2022 at 12:41:40PM +0530, Deepak Varma wrote:
> > On Sat, Oct 29, 2022 at 07:34:26PM +0200, Julia Lawall wrote:
> > >
> > >
> > > On Sat, 29 Oct 2022, Deepak R Varma wrote:
> > >
> > > > On Sat, Oct 29, 2022 at 09:32:50AM +0200, Greg Kroah-Hartman wrote:
> > > > > On Fri, Oct 28, 2022 at 07:00:05PM +0530, Deepak R Varma wrote:
> > > > > > The ARRAY_SIZE(foo) macro should be preferred over sizeof operator
> > > > > > based computation such as sizeof(foo)/sizeof(foo[0]) for finding
> > > > > > number of elements in an array. Issue identified using coccicheck.
> > > > > >
> > > > > > Signed-off-by: Deepak R Varma <drv@mailo.com>
> > > > > > ---
> > > > > > drivers/staging/fbtft/fbtft.h | 2 +-
> > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
> > > > > > index 2c2b5f1c1df3..5506a473be91 100644
> > > > > > --- a/drivers/staging/fbtft/fbtft.h
> > > > > > +++ b/drivers/staging/fbtft/fbtft.h
> > > > > > @@ -231,7 +231,7 @@ struct fbtft_par {
> > > > > > bool polarity;
> > > > > > };
> > > > > >
> > > > > > -#define NUMARGS(...) (sizeof((int[]){__VA_ARGS__}) / sizeof(int))
> > > > > > +#define NUMARGS(...) ARRAY_SIZE(((int[]){ __VA_ARGS__ }))
> > > > >
> > > > > Please please please test-build your patches before sending them out.
> > > > > To not do so just wastes reviewer resources :(
> > > >
> > > > Hello Greg,
> > > > I did build the .ko files by making the driver/staging/fbtft/ path. I verified
> > > > .o and .ko files were built.
> > > >
> > > > I did a make clean just now and was again able to rebuild without any errors.
> > > > Please see the attached log file.
> > > >
> > > > Is there something wrong with the way I am firing the build?
> > >
> > > The change is in the definition of a macro. The compiler won't help you
> > > in this case unless the macro is actually used in code that is compiled.
> > > Find the uses and check for any nearby ifdefs. For file foo.c you can
> > > also do make foo.i to see the result of reducing ifdef and expanding
> > > macros. Then you can see if the code you changed is actually included in
> > > the build.
> >
> > Okay. This is helpful. I understand. Looking into the file where the macro
> > expansion is reported to be failed.
>
> Hi Julia,
> I could see the macro expansions in the .i files for the fbtft-core.c and
> fb_hx8353d.c file. I am not sure why it built successfully on my x86 though. The
> error in Kerbel bot seems to be specific to ARM arch. I will try that later
> today. I am on the right track to the build error triage?
>
> Also, while reviewing the macro expansion, I saw change in the computation that
> seems odd to me. In the denominator of the expanded macro, there is a "+
> ((int)...." computation that I am not sure if is result of ARRAY_SIZE. I have
> attached the old anf the new .i file diff for your review. If you get a change
> could you help me understand why this additional computation is added to the
> denominator?
File now attached.
>
> Thank you,
> ./drv
> >
> > Thank you,
> > ./drv
> >
> > >
> > > julia
> > >
> >
> >
> >
>
>
>
[-- Attachment #2: fbtft-core.diff --]
[-- Type: text/x-diff, Size: 2398 bytes --]
74422c74422,74428
< # 242 "drivers/staging/fbtft/fbtft.h"
---
>
>
>
>
>
>
>
74644c74650
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF}) / sizeof(int)), MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF))
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF })) / sizeof((((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))), typeof(&(((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))[0])))); })))), MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF))
74647c74653
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF}) / sizeof(int)), MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF))
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF })) / sizeof((((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))), typeof(&(((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))[0])))); })))), MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF))
74650c74656
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_WRITE_MEMORY_START}) / sizeof(int)), MIPI_DCS_WRITE_MEMORY_START));
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_WRITE_MEMORY_START })) / sizeof((((int[]){ MIPI_DCS_WRITE_MEMORY_START }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_WRITE_MEMORY_START }))), typeof(&(((int[]){ MIPI_DCS_WRITE_MEMORY_START }))[0])))); })))), MIPI_DCS_WRITE_MEMORY_START));
WARNING: multiple messages have this Message-ID (diff)
From: Deepak R Varma <drv@mailo.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: linux-fbdev@vger.kernel.org, outreachy@lists.linux.dev,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count
Date: Mon, 31 Oct 2022 15:11:36 +0530 [thread overview]
Message-ID: <Y1+YUMCog7K5fVep@ubunlion> (raw)
In-Reply-To: <Y1+YC5OuycA5hLFx@ubunlion>
[-- Attachment #1: Type: text/plain, Size: 3238 bytes --]
On Mon, Oct 31, 2022 at 03:10:27PM +0530, Deepak Varma wrote:
> On Mon, Oct 31, 2022 at 12:41:40PM +0530, Deepak Varma wrote:
> > On Sat, Oct 29, 2022 at 07:34:26PM +0200, Julia Lawall wrote:
> > >
> > >
> > > On Sat, 29 Oct 2022, Deepak R Varma wrote:
> > >
> > > > On Sat, Oct 29, 2022 at 09:32:50AM +0200, Greg Kroah-Hartman wrote:
> > > > > On Fri, Oct 28, 2022 at 07:00:05PM +0530, Deepak R Varma wrote:
> > > > > > The ARRAY_SIZE(foo) macro should be preferred over sizeof operator
> > > > > > based computation such as sizeof(foo)/sizeof(foo[0]) for finding
> > > > > > number of elements in an array. Issue identified using coccicheck.
> > > > > >
> > > > > > Signed-off-by: Deepak R Varma <drv@mailo.com>
> > > > > > ---
> > > > > > drivers/staging/fbtft/fbtft.h | 2 +-
> > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
> > > > > > index 2c2b5f1c1df3..5506a473be91 100644
> > > > > > --- a/drivers/staging/fbtft/fbtft.h
> > > > > > +++ b/drivers/staging/fbtft/fbtft.h
> > > > > > @@ -231,7 +231,7 @@ struct fbtft_par {
> > > > > > bool polarity;
> > > > > > };
> > > > > >
> > > > > > -#define NUMARGS(...) (sizeof((int[]){__VA_ARGS__}) / sizeof(int))
> > > > > > +#define NUMARGS(...) ARRAY_SIZE(((int[]){ __VA_ARGS__ }))
> > > > >
> > > > > Please please please test-build your patches before sending them out.
> > > > > To not do so just wastes reviewer resources :(
> > > >
> > > > Hello Greg,
> > > > I did build the .ko files by making the driver/staging/fbtft/ path. I verified
> > > > .o and .ko files were built.
> > > >
> > > > I did a make clean just now and was again able to rebuild without any errors.
> > > > Please see the attached log file.
> > > >
> > > > Is there something wrong with the way I am firing the build?
> > >
> > > The change is in the definition of a macro. The compiler won't help you
> > > in this case unless the macro is actually used in code that is compiled.
> > > Find the uses and check for any nearby ifdefs. For file foo.c you can
> > > also do make foo.i to see the result of reducing ifdef and expanding
> > > macros. Then you can see if the code you changed is actually included in
> > > the build.
> >
> > Okay. This is helpful. I understand. Looking into the file where the macro
> > expansion is reported to be failed.
>
> Hi Julia,
> I could see the macro expansions in the .i files for the fbtft-core.c and
> fb_hx8353d.c file. I am not sure why it built successfully on my x86 though. The
> error in Kerbel bot seems to be specific to ARM arch. I will try that later
> today. I am on the right track to the build error triage?
>
> Also, while reviewing the macro expansion, I saw change in the computation that
> seems odd to me. In the denominator of the expanded macro, there is a "+
> ((int)...." computation that I am not sure if is result of ARRAY_SIZE. I have
> attached the old anf the new .i file diff for your review. If you get a change
> could you help me understand why this additional computation is added to the
> denominator?
File now attached.
>
> Thank you,
> ./drv
> >
> > Thank you,
> > ./drv
> >
> > >
> > > julia
> > >
> >
> >
> >
>
>
>
[-- Attachment #2: fbtft-core.diff --]
[-- Type: text/x-diff, Size: 2398 bytes --]
74422c74422,74428
< # 242 "drivers/staging/fbtft/fbtft.h"
---
>
>
>
>
>
>
>
74644c74650
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF}) / sizeof(int)), MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF))
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF })) / sizeof((((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))), typeof(&(((int[]){ MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF }))[0])))); })))), MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF))
74647c74653
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF}) / sizeof(int)), MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF))
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF })) / sizeof((((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))), typeof(&(((int[]){ MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF }))[0])))); })))), MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF))
74650c74656
< ((par)->fbtftops.write_register(par, (sizeof((int[]){MIPI_DCS_WRITE_MEMORY_START}) / sizeof(int)), MIPI_DCS_WRITE_MEMORY_START));
---
> ((par)->fbtftops.write_register(par, (sizeof(((int[]){ MIPI_DCS_WRITE_MEMORY_START })) / sizeof((((int[]){ MIPI_DCS_WRITE_MEMORY_START }))[0]) + ((int)(sizeof(struct { int:(-!!(__builtin_types_compatible_p(typeof((((int[]){ MIPI_DCS_WRITE_MEMORY_START }))), typeof(&(((int[]){ MIPI_DCS_WRITE_MEMORY_START }))[0])))); })))), MIPI_DCS_WRITE_MEMORY_START));
next prev parent reply other threads:[~2022-10-31 9:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 13:30 [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count Deepak R Varma
2022-10-28 23:56 ` kernel test robot
2022-10-29 7:32 ` Greg Kroah-Hartman
2022-10-29 7:32 ` Greg Kroah-Hartman
2022-10-29 16:58 ` Deepak R Varma
2022-10-29 16:58 ` Deepak R Varma
2022-10-29 17:34 ` Julia Lawall
2022-10-29 17:34 ` Julia Lawall
2022-10-31 7:11 ` Deepak R Varma
2022-10-31 7:11 ` Deepak R Varma
2022-10-31 9:40 ` Deepak R Varma
2022-10-31 9:40 ` Deepak R Varma
2022-10-31 9:41 ` Deepak R Varma [this message]
2022-10-31 9:41 ` Deepak R Varma
2022-10-31 12:05 ` Julia Lawall
2022-10-31 12:05 ` Julia Lawall
2022-11-04 12:01 ` Deepak R Varma
2022-11-04 12:01 ` Deepak R Varma
2022-11-04 14:42 ` Deepak R Varma
2022-11-04 14:42 ` Deepak R Varma
2022-11-09 15:00 ` Deepak R Varma
2022-11-09 15:00 ` Deepak R Varma
2022-11-09 16:00 ` Greg Kroah-Hartman
2022-11-09 16:00 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1+YUMCog7K5fVep@ubunlion \
--to=drv@mailo.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@inria.fr \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=outreachy@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.