From: Karsten Keil <keil@b1-systems.de>
To: isdn4linux@listserv.isdn4linux.de
Cc: Tilman Schmidt <tilman@imap.cc>, Joe Perches <joe@perches.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
i4ldeveloper@listserv.isdn4linux.de,
Hansjoerg Lipp <hjlipp@web.de>,
David Miller <davem@davemloft.net>
Subject: Re: [PATCH 6/9] ser_gigaset: checkpatch cleanup
Date: Tue, 27 Oct 2009 12:20:03 +0200 [thread overview]
Message-ID: <200910271120.04597.keil@b1-systems.de> (raw)
In-Reply-To: <4AE637D8.60809@imap.cc>
On Dienstag, 27. Oktober 2009 00:59:20 Tilman Schmidt wrote:
> Am 26.10.2009 01:54 schrieb Joe Perches:
> > On Sun, 2009-10-25 at 20:30 +0100, Tilman Schmidt wrote:
> >> Duly uglified as demanded by checkpatch.pl.
> >> diff --git a/drivers/isdn/gigaset/ser-gigaset.c
> >> b/drivers/isdn/gigaset/ser-gigaset.c index 3071a52..ac3409e 100644
> >> --- a/drivers/isdn/gigaset/ser-gigaset.c
> >> +++ b/drivers/isdn/gigaset/ser-gigaset.c
> >> @@ -164,9 +164,15 @@ static void gigaset_modem_fill(unsigned long data)
> >> {
> >> struct cardstate *cs = (struct cardstate *) data;
> >> struct bc_state *bcs;
> >> + struct sk_buff *nextskb;
> >> int sent = 0;
> >>
> >> - if (!cs || !(bcs = cs->bcs)) {
> >> + if (!cs) {
> >> + gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__);
> >> + return;
> >> + }
> >> + bcs = cs->bcs;
> >> + if (!bcs) {
> >> gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__);
> >> return;
> >> }
> >
> > perhaps:
> > if (!cs || !cs->bcs) {
> > gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__);
> > return;
> > }
> > bcs = cs->bcs;
>
> That would evaluate cs->bcs twice, and is also, in my experience,
gcc should handle this subsequent double evaluation well enough.
> significantly more prone to easily overlooked typos which result in
> checking a different pointer in the if statement than the one that's
> actually used in the subsequent assignment.
>
Yes this may happen, but more often a = in if statements should be a ==.
The kernel code style says only one statement per line, which implies no
assignments in if statements, so we should follow this.
The checkpatch.pl script complain about these issues.
Yes sometimes in the past (while preparing some old code for kernel submit)
I was not very happy about all these rules, it take lot time to reach zero
reports from checkpatch.
But it make lot of sense in the long term, currently I have to debug code
written without any code style, it is really, really painful and I need 5-10
times more time for simple understanding the basic function of the code.
Karsten
next prev parent reply other threads:[~2009-10-27 10:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-25 19:29 [PATCH 0/9] Gigaset driver patches for 2.6.33 Tilman Schmidt
2009-10-25 19:29 ` [PATCH 1/9] gigaset: CAPI module readability improvements Tilman Schmidt
2009-10-25 19:29 ` [PATCH 2/9] gigaset: fix format string typo in CAPI dial command Tilman Schmidt
2009-10-25 19:29 ` [PATCH 3/9] gigaset: fix bad assumptions about CAPI skbuffs Tilman Schmidt
2009-10-25 19:30 ` [PATCH 4/9] usb_gigaset: code cleanup Tilman Schmidt
2009-10-25 19:30 ` [PATCH 5/9] gigaset: checkpatch cleanup Tilman Schmidt
2009-10-25 19:30 ` [PATCH 6/9] ser_gigaset: " Tilman Schmidt
2009-10-25 20:37 ` Alan Cox
2009-10-25 23:36 ` Tilman Schmidt
2009-10-26 0:54 ` Joe Perches
2009-10-26 23:59 ` Tilman Schmidt
2009-10-27 0:14 ` Joe Perches
2009-10-27 10:20 ` Karsten Keil [this message]
2009-10-25 19:30 ` [PATCH 7/9] bas_gigaset: " Tilman Schmidt
2009-10-25 19:30 ` [PATCH 8/9] gigaset: checkpatch cleanup of ev-layer.c Tilman Schmidt
2009-10-25 19:30 ` [PATCH 9/9] gigaset: convert strcmp chain to table lookup Tilman Schmidt
2009-10-29 8:37 ` [PATCH 0/9] Gigaset driver patches for 2.6.33 David Miller
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=200910271120.04597.keil@b1-systems.de \
--to=keil@b1-systems.de \
--cc=davem@davemloft.net \
--cc=hjlipp@web.de \
--cc=i4ldeveloper@listserv.isdn4linux.de \
--cc=isdn4linux@listserv.isdn4linux.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).