Skip to content

Commit

Permalink
staging: fbtft: Use ARRAY_SIZE() to get argument count
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
drvgithubuser authored and intel-lab-lkp committed Oct 28, 2022
1 parent 8cd7565 commit 74374d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/fbtft/fbtft.h
Expand Up @@ -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__))
Expand Down

0 comments on commit 74374d9

Please sign in to comment.