From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Joe Perches <joe@perches.com>
Cc: Arend van Spriel <arend@broadcom.com>,
Andy Whitcroft <apw@canonical.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: checkpatch complaint
Date: Wed, 8 Feb 2012 21:05:51 -0800 [thread overview]
Message-ID: <20120209050551.GA25763@ericsson.com> (raw)
In-Reply-To: <1328744534.6909.2.camel@joe2Laptop>
On Wed, Feb 08, 2012 at 06:42:14PM -0500, Joe Perches wrote:
> On Wed, 2012-02-08 at 21:51 +0100, Arend van Spriel wrote:
> > checkpatch complains on code below and I must overlook something or
> > checkpatch gives a false negative/positive/whatever:
> >
> > #define IFPTR(usb, idx) ((usb)->actconfig->interface[(idx)])
> > #define IFALTS(usb, idx) (IFPTR((usb), (idx))->altsetting[0])
> > #define IFDESC(usb, idx) IFALTS((usb), (idx)).desc
> > #define IFEPDESC(usb, idx, ep) \
> > (IFALTS((usb), (idx)).endpoint[(ep)]).desc
> >
> > checkpatch errors:
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #169: FILE: drivers/net/wireless/brcm80211/brcmfmac/usb.c:58:
> > +#define IFDESC(usb, idx) (IFALTS((usb), (idx))).desc
> >
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #170: FILE: drivers/net/wireless/brcm80211/brcmfmac/usb.c:59:
> > +#define IFEPDESC(usb, idx, ep) ((IFALTS((usb),
> > (idx))).endpoint[(ep)]).desc
> >
> > Any ideas? I tried extra parenthesis around IFALTS but that does not
> > resolve it.
>
> I think the entries should be surround by ()
> I think it's reasonable too.
>
> I tried:
>
> $ cat cp.c
> #define IFPTR(usb, idx) ((usb)->actconfig->interface[(idx)])
> #define IFALTS(usb, idx) (IFPTR((usb), (idx))->altsetting[0])
> #define IFDESC(usb, idx) (IFALTS((usb), (idx)).desc)
> #define IFEPDESC(usb, idx, ep) ((IFALTS((usb), (idx)).endpoint[(ep)]).desc)
>
> $ ./scripts/checkpatch.pl -f cp.c
> total: 0 errors, 0 warnings, 5 lines checked
>
> cp.c has no obvious style problems and is ready for submission.
>
Hi Joe,
different example, same message:
ERROR: Macros with complex values should be enclosed in parenthesis
#339: FILE: hwmon/ltc4245.c:339:
+#define LTC4245_ALARM(name, mask, reg) \
+ static SENSOR_DEVICE_ATTR_2(name, S_IRUGO, \
+ ltc4245_show_alarm, NULL, (mask), reg)
and:
ERROR: Macros with complex values should be enclosed in parenthesis
#585: FILE: hwmon/pc87360.c:585:
+#define VIN_UNIT_ATTRS(X) \
+ &in_input[X].dev_attr.attr, \
+ &in_status[X].dev_attr.attr, \
+ &in_min[X].dev_attr.attr, \
+ &in_max[X].dev_attr.attr, \
+ &in_min_alarm[X].dev_attr.attr, \
+ &in_max_alarm[X].dev_attr.attr
and:
ERROR: Macros with multiple statements should be enclosed in a do - while loop
#291: FILE: hwmon/sis5595.c:291:
+#define show_in_offset(offset) \
+static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
+ show_in, NULL, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
+ show_in_min, set_in_min, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
+ show_in_max, set_in_max, offset);
Those are all pretty common in the hwmon subsystem and all quite annnoying.
Other than labeling them as "false positive", I have no idea what to do about it.
Sure, we could replace all the macros with immediate code, but that doesn't sound
very compelling. If you have an idea, please let me know.
Thanks,
Guenter
next prev parent reply other threads:[~2012-02-09 5:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 20:51 checkpatch complaint Arend van Spriel
2012-02-08 23:42 ` Joe Perches
2012-02-09 5:05 ` Guenter Roeck [this message]
2012-02-09 10:20 ` Bernd Petrovitsch
2012-02-09 10:06 ` Dan Carpenter
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=20120209050551.GA25763@ericsson.com \
--to=guenter.roeck@ericsson.com \
--cc=apw@canonical.com \
--cc=arend@broadcom.com \
--cc=dan.carpenter@oracle.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox