Re: [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count

Deepak R Varma
2022-11-04T12:01:39Z

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

On Mon, Oct 31, 2022 at 01:05:32PM +0100, Julia Lawall wrote:
>
>
> I took a look, but it's pretty complex. You could take the code and
> reorganize it so that it is more readable, and then take the definition of
> the ARRAY_SIZE macro, to better see what is going on.
>
> julia
>

Hello Greg, Julia,
I was able to successfully build the fbtft object file for arm architecture as
well. I used gcc 6.5.0 and 9.5.0 tool chains. It was successful using both. I
have attached the build log from my machine for your reference.

I am also looking at the .i file and rearrange the expanded macro to understand
it. However, since it is built successfully, I am not sure if that is truly the
problem area.

Should I resend the patch and check if it still errors the kernel build bot?
Anything else I can try?

Thank you,
./drv

[-- Attachment #2: fbtft_build.log --]
[-- Type: text/plain, Size: 3034 bytes --]

drv@qemulion:~/git/kernels/staging$ git status
On branch patches-11022022
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: drivers/staging/fbtft/fbtft.h

no changes added to commit (use "git add" and/or "git commit -a")
drv@qemulion:~/git/kernels/staging$ git diff
diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index 2c2b5f1c1df3..f2ed23123849 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__ }))

#define write_reg(par, ...) \
((par)->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__))
drv@qemulion:~/git/kernels/staging$ make CROSS_COMPILE=/opt/gcc-9.5.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- --jobs=8 ARCH=arm drivers/staging/fbtft/fbtft-core.o
CALL scripts/checksyscalls.sh
CC drivers/staging/fbtft/fbtft-core.o
drv@qemulion:~/git/kernels/staging$ make CROSS_COMPILE=/opt/gcc-9.5.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- --jobs=8 ARCH=arm drivers/staging/fbtft/
CALL scripts/checksyscalls.sh
CC drivers/staging/fbtft/fbtft-sysfs.o
CC drivers/staging/fbtft/fbtft-bus.o
CC drivers/staging/fbtft/fbtft-io.o
CC drivers/staging/fbtft/fb_agm1264k-fl.o
CC drivers/staging/fbtft/fb_bd663474.o
CC drivers/staging/fbtft/fb_hx8340bn.o
CC drivers/staging/fbtft/fb_hx8347d.o
CC drivers/staging/fbtft/fb_hx8353d.o
CC drivers/staging/fbtft/fb_hx8357d.o
CC drivers/staging/fbtft/fb_ili9163.o
CC drivers/staging/fbtft/fb_ili9320.o
CC drivers/staging/fbtft/fb_ili9325.o
CC drivers/staging/fbtft/fb_ili9340.o
CC drivers/staging/fbtft/fb_ili9341.o
CC drivers/staging/fbtft/fb_ili9481.o
CC drivers/staging/fbtft/fb_ili9486.o
CC drivers/staging/fbtft/fb_pcd8544.o
CC drivers/staging/fbtft/fb_ra8875.o
CC drivers/staging/fbtft/fb_s6d02a1.o
CC drivers/staging/fbtft/fb_s6d1121.o
CC drivers/staging/fbtft/fb_seps525.o
CC drivers/staging/fbtft/fb_sh1106.o
CC drivers/staging/fbtft/fb_ssd1289.o
CC drivers/staging/fbtft/fb_ssd1305.o
CC drivers/staging/fbtft/fb_ssd1306.o
CC drivers/staging/fbtft/fb_ssd1325.o
CC drivers/staging/fbtft/fb_ssd1331.o
CC drivers/staging/fbtft/fb_ssd1351.o
CC drivers/staging/fbtft/fb_st7735r.o
CC drivers/staging/fbtft/fb_st7789v.o
CC drivers/staging/fbtft/fb_tinylcd.o
CC drivers/staging/fbtft/fb_tls8204.o
CC drivers/staging/fbtft/fb_uc1611.o
CC drivers/staging/fbtft/fb_uc1701.o
CC drivers/staging/fbtft/fb_upd161704.o
AR drivers/staging/fbtft/built-in.a
drv@qemulion:~/git/kernels/staging$