staging: nvec: Silence unused argument warning in NVEC_PHD macro
Subsystems (3)
PATCH 1/1 staging: nvec: Silence unused argument warning in NVEC_PHD macro
The NVEC_PHD macro was defined with three arguments (str, buf, len) that were not used in its empty body, causing a compiler warning.
This patch silences the warning by explicitly casting the unused arguments to (void), making the intent clear without changing functionality.
--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -28,7 +28,7 @@print_hex_dump (KERN_DEBUG , str,DUMP_PREFIX_NONE , \ 16, 1, buf, len, false)#else -#define NVEC_PHD (str, buf, len) do { } while (0) +#define NVEC_PHD (str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)#endif enum ps2_subcmds {
Signature · 1 line
2.50.1
Quoted 8 lines · Mohammed Guermoud
The
NVEC_PHDmacro was defined with three arguments (str, buf, len) that were not used in its empty body, causing a compiler warning.This patch silences the warning by explicitly casting the unused arguments to (void), making the intent clear without changing functionality.
Signed-off-by Mohammed Guermoud <[email protected]>
What's the warning. Does it break the build since we're using -Werror?
I feel like in the end, I'm going to say just ignore the compiler warning since this is not a bug in the code but obviously if it breaks the build then that's a different story.
regards,
dan carpenter
Greg KH
maintainerQuoted 17 lines · Mohammed Guermoud
The
NVEC_PHDmacro was defined with three arguments (str, buf, len) that were not used in its empty body, causing a compiler warning.This patch silences the warning by explicitly casting the unused arguments to (void), making the intent clear without changing functionality.
Signed-off-by Mohammed Guermoud <[email protected]>--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/nvec/nvec_ps2.c +0
-0
drivers/staging/nvec/nvec_ps2.c line 31
Quoted 5 lines
drivers/staging/nvec/nvec_ps2.c +1
-1@@ -28,7 +28,7 @@print_hex_dump (KERN_DEBUG , str,DUMP_PREFIX_NONE , \ 16, 1, buf, len, false)#else -#define NVEC_PHD (str, buf, len) do { } while (0) +#define NVEC_PHD (str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)
As Dan said, what is the warning?
And this isn't the best/proper way to handle this type of issue. Best is to make an inline function that does nothing, as that way you properly check the variable types.
But, I'll push back and say why is this even needed at all? As NVEC_PS2_DEBUG is never defined, why not just remove them?
thanks,
greg k-h
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Mohammed,
kernel test robot noticed the following build errors:
[auto build test ERROR on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Mohammed-Guermoud/staging-nvec-Silence-unused-argument-warning-in-NVEC_PHD-macro/20250818-032647 base: staging/staging-testing patch link: https://lore.kernel.org/r/20250817192425.12983-1-mohammed.guermoud%40gmail.com patch subject: [PATCH] staging: nvec: Silence unused argument warning in NVEC_PHD macro config: arm-defconfig (https://download.01.org/0day-ci/archive/20250818/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250818/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/staging/nvec/nvec_ps2.c:80:51: error: invalid operands to binary expression ('void' and 'int')
80 | NVEC_PHD("ps/2 mouse reply: ", &msg[4], msg[1] - 2);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
drivers/staging/nvec/nvec_ps2.c:31:66: note: expanded from macro 'NVEC_PHD'
31 | #define NVEC_PHD(str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)
| ~~~~~~^~~
drivers/staging/nvec/nvec_ps2.c:84:52: error: invalid operands to binary expression ('void' and 'int')
84 | NVEC_PHD("unhandled mouse event: ", msg, msg[1] + 2);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
drivers/staging/nvec/nvec_ps2.c:31:66: note: expanded from macro 'NVEC_PHD'
31 | #define NVEC_PHD(str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)
| ~~~~~~^~~2 errors generated.
vim +80 drivers/staging/nvec/nvec_ps2.c
32890b98308613 Marc Dietrich 2011-05-19 62
32890b98308613 Marc Dietrich 2011-05-19 63 static int nvec_ps2_notifier(struct notifier_block *nb,
32890b98308613 Marc Dietrich 2011-05-19 64 unsigned long event_type, void *data)
32890b98308613 Marc Dietrich 2011-05-19 65 {
32890b98308613 Marc Dietrich 2011-05-19 66 int i;
0df8f51eed5067 Ben Marsh 2016-03-10 67 unsigned char *msg = data;
32890b98308613 Marc Dietrich 2011-05-19 68
32890b98308613 Marc Dietrich 2011-05-19 69 switch (event_type) {
32890b98308613 Marc Dietrich 2011-05-19 70 case NVEC_PS2_EVT:
1e46e6273bc62d Julian Andres Klode 2011-09-27 71 for (i = 0; i < msg[1]; i++)
1e46e6273bc62d Julian Andres Klode 2011-09-27 72 serio_interrupt(ps2_dev.ser_dev, msg[2 + i], 0);
0eedab704ed93d Marc Dietrich 2011-12-26 73 NVEC_PHD("ps/2 mouse event: ", &msg[2], msg[1]);
32890b98308613 Marc Dietrich 2011-05-19 74 return NOTIFY_STOP;
32890b98308613 Marc Dietrich 2011-05-19 75
32890b98308613 Marc Dietrich 2011-05-19 76 case NVEC_PS2:
0eedab704ed93d Marc Dietrich 2011-12-26 77 if (msg[2] == 1) {
32890b98308613 Marc Dietrich 2011-05-19 78 for (i = 0; i < (msg[1] - 2); i++)
32890b98308613 Marc Dietrich 2011-05-19 79 serio_interrupt(ps2_dev.ser_dev, msg[i + 4], 0);
0eedab704ed93d Marc Dietrich 2011-12-26 @80 NVEC_PHD("ps/2 mouse reply: ", &msg[4], msg[1] - 2);
32890b98308613 Marc Dietrich 2011-05-19 81 }
32890b98308613 Marc Dietrich 2011-05-19 82
0eedab704ed93d Marc Dietrich 2011-12-26 83 else if (msg[1] != 2) /* !ack */
0eedab704ed93d Marc Dietrich 2011-12-26 84 NVEC_PHD("unhandled mouse event: ", msg, msg[1] + 2);
32890b98308613 Marc Dietrich 2011-05-19 85 return NOTIFY_STOP;
32890b98308613 Marc Dietrich 2011-05-19 86 }
32890b98308613 Marc Dietrich 2011-05-19 87
32890b98308613 Marc Dietrich 2011-05-19 88 return NOTIFY_DONE;
32890b98308613 Marc Dietrich 2011-05-19 89 }
32890b98308613 Marc Dietrich 2011-05-19 90 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Mohammed,
Quoted 8 lines · Mohammed Guermoud
The
NVEC_PHDmacro was defined with three arguments (str, buf, len) that were not used in its empty body, causing a compiler warning.This patch silences the warning by explicitly casting the unused arguments to (void), making the intent clear without changing functionality.
Signed-off-by Mohammed Guermoud <[email protected]>
Thanks for your patch!
drivers/staging/nvec/nvec_ps2.c line 34
Quoted 11 lines
drivers/staging/nvec/nvec_ps2.c +1
-1@@ -28,7 +28,7 @@print_hex_dump (KERN_DEBUG , str,DUMP_PREFIX_NONE , \ 16, 1, buf, len, false)#else -#define NVEC_PHD (str, buf, len) do { } while (0) +#define NVEC_PHD (str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)#endif enum ps2_subcmds {
The proper solution would be to remove the custom NVEC_PHD() macro (and NVEC_PS2_DEBUG), and just call print_hex_dump_debug() directly instead.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Greg, Dan, and Geert,
Thank you all for the detailed feedback. This has been a great learning experience.
My initial patch was incorrect and broke the build, as the test robot found.
Following Greg's advice, I will send a v2 patch that removes the unused NVEC_PHD macro and all the places it is used.
Thanks,
Mohammed
Mohammed GUERMOUD
Software Architect
Stellantis (Formerly Groupe PSA Peugeot Citroën) - Morocco
Quoted 41 lines · Geert Uytterhoeven
Hi Mohammed,
Quoted 8 lines · Mohammed Guermoud
The
NVEC_PHDmacro was defined with three arguments (str, buf, len) that were not used in its empty body, causing a compiler warning.This patch silences the warning by explicitly casting the unused arguments to (void), making the intent clear without changing functionality.
Signed-off-by Mohammed Guermoud <[email protected]>Thanks for your patch!
drivers/staging/nvec/nvec_ps2.c line 34
Quoted 11 lines
drivers/staging/nvec/nvec_ps2.c +1
-1@@ -28,7 +28,7 @@print_hex_dump (KERN_DEBUG , str,DUMP_PREFIX_NONE , \ 16, 1, buf, len, false)#else -#define NVEC_PHD (str, buf, len) do { } while (0) +#define NVEC_PHD (str, buf, len) do { (void)str; (void)buf; (void)len; } while (0)#endif enum ps2_subcmds {The proper solution would be to remove the custom
NVEC_PHD()macro (andNVEC_PS2_DEBUG), and just callprint_hex_dump_debug()directly instead.Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds