From: Randy Dunlap <rdunlap@xenotime.net>
To: Tilman Schmidt <tilman@imap.cc>
Cc: LKML <linux-kernel@vger.kernel.org>, Andy Whitcroft <apw@canonical.com>
Subject: Re: checkpatch.pl false positive? "ERROR: do not use assignment in if condition"
Date: Tue, 20 Oct 2009 08:58:20 -0700 [thread overview]
Message-ID: <20091020085820.e312a38b.rdunlap@xenotime.net> (raw)
In-Reply-To: <4ADDDC55.8020809@imap.cc>
On Tue, 20 Oct 2009 17:50:45 +0200 Tilman Schmidt wrote:
> The command
> ./scripts/checkpatch.pl -f drivers/isdn/gigaset/bas-gigaset.c
> produces a lot of "ERROR" messages like these:
>
> ERROR: do not use assignment in if condition
> #608: FILE: isdn/gigaset/bas-gigaset.c:608:
> + if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) {
>
> ERROR: do not use assignment in if condition
> #745: FILE: isdn/gigaset/bas-gigaset.c:745:
> + if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) {
>
> ERROR: do not use assignment in if condition
> #753: FILE: isdn/gigaset/bas-gigaset.c:753:
> + if ((rc = atread_submit(cs, BAS_TIMEOUT)) < 0) {
>
> As far as I can see there's nothing wrong with these lines. In particular,
> I cannot find anything in Documentation/CodingStyle that would prohibit an
> assignment inside an 'if' condition.
Yes, we don't try to list Every Possible Problem in CodingStyle,
but emails on lkml over the past several years try to discourage such
assignments inside if's because they can be confusing, difficult to read,
and generally are not helping to produce any better code output than
using:
ret = usb_submit_urb(args);
if (ret) {
foo;
bar;
blah();
}
> PS: I know the file has other problems. That's why I'm trying to
> checkpatch it in the first place.
---
~Randy
next prev parent reply other threads:[~2009-10-20 15:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-20 15:50 Tilman Schmidt
2009-10-20 15:58 ` Randy Dunlap [this message]
2009-10-20 16:24 ` Andy Whitcroft
2009-10-21 17:07 ` Tilman Schmidt
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=20091020085820.e312a38b.rdunlap@xenotime.net \
--to=rdunlap@xenotime.net \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tilman@imap.cc \
/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
all inboxes | Powered by JetHome®