From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: linux-kernel@vger.kernel.org, dm-devel@redhat.com,
"Mikulas Patocka" <mpatocka@redhat.com>,
"Américo Wang" <xiyou.wangcong@gmail.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Alasdair G Kergon" <agk@redhat.com>
Subject: Re: [PATCH] Drop 80-character limit in checkpatch.pl
Date: Fri, 18 Dec 2009 14:55:34 +0100 [thread overview]
Message-ID: <200912181455.34664.bzolnier@gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.00.0912181400130.21496@twin.jikos.cz>
On Friday 18 December 2009 02:04:37 pm Jiri Kosina wrote:
> On Thu, 17 Dec 2009, Bartlomiej Zolnierkiewicz wrote:
>
> > > > I like this patch, this is actually what I wanted to do.
> > >
> > > I have nothing against a switch, but it had better default to off.
> > >
> > > The whole 80-char limit is insane. It results in insane "fixes". Just
> > > about every time somebody "improves" a patch due to the warning, the
> > > result is worse than the original patch.
> >
> > Examples? :)
>
> balance_leaf() in fs/reiserfs/do_balan.c
>
> Example picked totally at random:
>
> set_le_ih_k_offset(ih,
> le_ih_k_offset(ih) +
> (tb->
> lbytes <<
> (is_indirect_le_ih
> (ih) ? tb->tb_sb->
> s_blocksize_bits -
> UNFM_P_SHIFT :
> 0)));
>
> See how everything is nicely aligned to 80 cols?
I see but the above code is an utter crap anyway.
Firstly what kind of a function parameter is that:
le_ih_k_offset(ih) + (tb->lbytes << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0))
?
[ BTW 'tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT' construct is used five
times in balance_leaf() and is a likely candidate for helper / macro. ]
More importantly the whole balance_leaf() function is almost 1400 LOC (!)
big and impossible to read: code for handling particular 'switch' blocks
should be factored out into separate functions etc.
The point I was making is that the once we remove the limit we don't have
other tool to _automatically_ point suspicious code areas (yes, I would
also prefer intelligent static code checker over dumb limit but it simply
not here as things are today and dumb limit works surprisingly well most
of the time -- please note how that the structural problem with the code
example given is immediately visible with the current limit).
> Generally, don't look at this function after having a good lunch you want
> to keep. You have been warned.
No worries, I visit dark places (ide, staging, ..) and come back alive.. ;)
--
Bartlomiej Zolnierkiewicz
WARNING: multiple messages have this Message-ID (diff)
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Américo Wang" <xiyou.wangcong@gmail.com>,
"Mikulas Patocka" <mpatocka@redhat.com>,
linux-kernel@vger.kernel.org,
"Alasdair G Kergon" <agk@redhat.com>,
dm-devel@redhat.com
Subject: Re: [PATCH] Drop 80-character limit in checkpatch.pl
Date: Fri, 18 Dec 2009 14:55:34 +0100 [thread overview]
Message-ID: <200912181455.34664.bzolnier@gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.00.0912181400130.21496@twin.jikos.cz>
On Friday 18 December 2009 02:04:37 pm Jiri Kosina wrote:
> On Thu, 17 Dec 2009, Bartlomiej Zolnierkiewicz wrote:
>
> > > > I like this patch, this is actually what I wanted to do.
> > >
> > > I have nothing against a switch, but it had better default to off.
> > >
> > > The whole 80-char limit is insane. It results in insane "fixes". Just
> > > about every time somebody "improves" a patch due to the warning, the
> > > result is worse than the original patch.
> >
> > Examples? :)
>
> balance_leaf() in fs/reiserfs/do_balan.c
>
> Example picked totally at random:
>
> set_le_ih_k_offset(ih,
> le_ih_k_offset(ih) +
> (tb->
> lbytes <<
> (is_indirect_le_ih
> (ih) ? tb->tb_sb->
> s_blocksize_bits -
> UNFM_P_SHIFT :
> 0)));
>
> See how everything is nicely aligned to 80 cols?
I see but the above code is an utter crap anyway.
Firstly what kind of a function parameter is that:
le_ih_k_offset(ih) + (tb->lbytes << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0))
?
[ BTW 'tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT' construct is used five
times in balance_leaf() and is a likely candidate for helper / macro. ]
More importantly the whole balance_leaf() function is almost 1400 LOC (!)
big and impossible to read: code for handling particular 'switch' blocks
should be factored out into separate functions etc.
The point I was making is that the once we remove the limit we don't have
other tool to _automatically_ point suspicious code areas (yes, I would
also prefer intelligent static code checker over dumb limit but it simply
not here as things are today and dumb limit works surprisingly well most
of the time -- please note how that the structural problem with the code
example given is immediately visible with the current limit).
> Generally, don't look at this function after having a good lunch you want
> to keep. You have been warned.
No worries, I visit dark places (ide, staging, ..) and come back alive.. ;)
--
Bartlomiej Zolnierkiewicz
next prev parent reply other threads:[~2009-12-18 13:55 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-15 21:57 [PATCH] Drop 80-character limit in checkpatch.pl Mikulas Patocka
2009-12-15 21:57 ` Mikulas Patocka
2009-12-15 22:26 ` Bartlomiej Zolnierkiewicz
2009-12-15 22:26 ` Bartlomiej Zolnierkiewicz
2009-12-17 9:31 ` Américo Wang
2009-12-17 15:14 ` Linus Torvalds
2009-12-17 15:14 ` Linus Torvalds
2009-12-17 15:18 ` Bartlomiej Zolnierkiewicz
2009-12-17 15:18 ` Bartlomiej Zolnierkiewicz
2009-12-17 15:37 ` Linus Torvalds
2009-12-17 16:08 ` Bartlomiej Zolnierkiewicz
2009-12-17 16:08 ` Bartlomiej Zolnierkiewicz
2009-12-17 16:21 ` Linus Torvalds
2009-12-17 16:21 ` Linus Torvalds
2009-12-17 16:30 ` Janakiram Sistla
2009-12-17 18:05 ` Andi Kleen
2009-12-18 13:31 ` Pádraig Brady
2009-12-18 16:32 ` Mikulas Patocka
2009-12-18 16:32 ` Mikulas Patocka
2009-12-18 22:33 ` Krzysztof Halasa
2009-12-18 13:04 ` Jiri Kosina
2009-12-18 13:04 ` Jiri Kosina
2009-12-18 13:55 ` Bartlomiej Zolnierkiewicz [this message]
2009-12-18 13:55 ` Bartlomiej Zolnierkiewicz
2009-12-18 14:39 ` Krzysztof Halasa
2009-12-18 14:39 ` Krzysztof Halasa
2009-12-27 17:15 ` Jon Smirl
2009-12-21 6:32 ` Paul Mundt
2009-12-22 15:10 ` Jiri Kosina
2009-12-16 10:58 ` Andi Kleen
2009-12-16 19:59 ` Alex Chiang
2009-12-17 6:12 ` Paul Mundt
2009-12-17 6:12 ` Paul Mundt
2009-12-17 8:34 ` Krzysztof Halasa
2009-12-17 23:29 ` Mikulas Patocka
2009-12-17 23:29 ` Mikulas Patocka
2009-12-17 23:35 ` Al Viro
2009-12-18 4:29 ` Valdis.Kletnieks
2009-12-18 5:12 ` [PATCH] scripts/checkpatch.pl: Change long line warning to 105 chars Joe Perches
2009-12-18 5:57 ` Paul Mundt
2009-12-18 5:57 ` Paul Mundt
2009-12-18 17:43 ` Linus Torvalds
2009-12-18 17:54 ` Joe Perches
2009-12-18 18:41 ` Andi Kleen
2009-12-18 14:37 ` Krzysztof Halasa
2009-12-18 14:37 ` Krzysztof Halasa
2009-12-18 15:12 ` Alasdair G Kergon
2009-12-18 15:12 ` [dm-devel] " Alasdair G Kergon
2009-12-18 16:58 ` Randy Dunlap
2009-12-18 16:58 ` [dm-devel] " Randy Dunlap
2009-12-18 17:12 ` Mikulas Patocka
2009-12-18 17:12 ` [dm-devel] " Mikulas Patocka
2009-12-18 22:36 ` Krzysztof Halasa
2009-12-18 17:31 ` Joe Perches
2009-12-18 17:31 ` Joe Perches
2009-12-18 14:28 ` [PATCH] Drop 80-character limit in checkpatch.pl Krzysztof Halasa
2009-12-18 14:28 ` Krzysztof Halasa
2009-12-18 14:52 ` kevin granade
2009-12-18 16:43 ` Mikulas Patocka
2009-12-18 16:43 ` Mikulas Patocka
2009-12-18 16:50 ` Linus Torvalds
2009-12-18 16:50 ` Linus Torvalds
2009-12-18 17:09 ` Mikulas Patocka
2009-12-18 17:09 ` Mikulas Patocka
2009-12-18 17:28 ` Linus Torvalds
2009-12-18 17:28 ` Linus Torvalds
2009-12-18 21:15 ` kevin granade
2009-12-18 15:11 ` Bartlomiej Zolnierkiewicz
2009-12-17 22:37 ` Mikulas Patocka
2009-12-17 22:37 ` Mikulas Patocka
2009-12-17 23:12 ` Paul Mundt
2009-12-17 23:12 ` Paul Mundt
2009-12-17 23:33 ` Mikulas Patocka
2009-12-17 23:33 ` Mikulas Patocka
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=200912181455.34664.bzolnier@gmail.com \
--to=bzolnier@gmail.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=xiyou.wangcong@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.