* CHECK: Macro argument reuse
@ 2022-02-02 10:48 Hegbeli, Ciprian
2022-02-05 17:43 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Hegbeli, Ciprian @ 2022-02-02 10:48 UTC (permalink / raw)
To: linux-iio@vger.kernel.org
Hi,
The driver I'm working on has channels which can be configured similarly but with small changes. In order to simplify the code, I used macros with arguments for the parts that are different.
Unfortunately this leads to warnings during the checkpatch with --strict .
CHECK: Macro argument reuse 'num' - possible side-effects?
+#define ADE9078_POWER_FACTOR_CHANNEL(num, name) { \
+ .type = IIO_POWER, \
+ .channel = num, \
+ .address = ADE9078_ADDR_ADJUST(ADE9078_REG_APF, num), \
+ .extend_name = name "_factor", \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_SCALE), \
+ .scan_index = -1 \
+}
Is there any way to fix this warning without adding more arguments?
In this case, can it be ignored?
Regards,
Ciprian
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: CHECK: Macro argument reuse
2022-02-02 10:48 CHECK: Macro argument reuse Hegbeli, Ciprian
@ 2022-02-05 17:43 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-02-05 17:43 UTC (permalink / raw)
To: Hegbeli, Ciprian; +Cc: linux-iio@vger.kernel.org
On Wed, 2 Feb 2022 10:48:51 +0000
"Hegbeli, Ciprian" <Ciprian.Hegbeli@analog.com> wrote:
> Hi,
>
> The driver I'm working on has channels which can be configured similarly but with small changes. In order to simplify the code, I used macros with arguments for the parts that are different.
> Unfortunately this leads to warnings during the checkpatch with --strict .
>
> CHECK: Macro argument reuse 'num' - possible side-effects?
> +#define ADE9078_POWER_FACTOR_CHANNEL(num, name) { \
> + .type = IIO_POWER, \
> + .channel = num, \
> + .address = ADE9078_ADDR_ADJUST(ADE9078_REG_APF, num), \
> + .extend_name = name "_factor", \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> + BIT(IIO_CHAN_INFO_SCALE), \
> + .scan_index = -1 \
> +}
>
> Is there any way to fix this warning without adding more arguments?
> In this case, can it be ignored?
It's a request to 'CHECK' that it looks right, not a warning or error
because it may well be fine. In this case, I'd hope it's fine
as long as you are only passing constant values in for num.
So check what it asks you to check and if it's fine ignore the message.
Jonathan
>
> Regards,
> Ciprian
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-05 17:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-02 10:48 CHECK: Macro argument reuse Hegbeli, Ciprian
2022-02-05 17:43 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox