public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.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 08:12:40 +0900	[thread overview]
Message-ID: <20091217231240.GA1421@linux-sh.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0912171725370.21142@hs20-bc2-1.build.redhat.com>

On Thu, Dec 17, 2009 at 05:37:57PM -0500, Mikulas Patocka wrote:
> On Thu, 17 Dec 2009, Paul Mundt wrote:
> > On Tue, Dec 15, 2009 at 04:57:49PM -0500, Mikulas Patocka wrote:
> > > (5) Wrapping makes long expressions harder to understand
> > > --------------------------------------------------------
> > > 
> > > If I have a complex expression, I do not try to wrap it at predefined
> > > 80-column boundaries, but at logical boundaries within the expression to make
> > > it more readable (the brain can't find matching parentheses fast, so we can
> > > help it by aligning the code according to topmost terms in the expression).
> > > 
> > > Example:
> > > 				if (unlikely(call_some_function(s, value) != RET
> > > _SUCCESS) ||
> > > 				    (var_1 == prev_var_1 && var_2 == prev_var_2)
> > >  ||
> > > 				    flags & (FLAG_1 | FLAG_2) ||
> > > 				    some_other_condition) {
> > > 				}
> > > 
> > > Now, if we impose 80-column limit, we get this. One may argue that is looks
> > > aesthetically better, but it is also less intelligible than the previous
> > > version:
> > > 				if (unlikely(call_some_function(s, value) !=
> > > 				    RET_SUCCESS) || (var_1 == prev_var_1 &&
> > > 				    var_2 == prev_var_2) || flags & (FLAG_1 |
> > > 				    FLAG_2) || some_other_condition) {
> > > 				}
> > > 
> > For starters, this is just crap. If you're writing code like this, then
> > line wrapping is really the least of your concerns. Take your function
> > return value and assign it to a variable before testing it in unlikely()
> > as per existing conventions and most of this goes away in this example.
> 
> I wouldn't say that this is better:
> 				int csf_failed, vars_equal, flags_12;
> 
> 				...
> 
> 				csf_failed = call_some_function(s, value) != RET_SUCCESS;
> 				vars_equal = var_1 == prev_var_1 && var_2 == prev_var_2;
> 				flags_12 = flags & (FLAG_1 | FLAG_2);
> 				if (unlikely(csf_failed) || vars_equal ||
> 				    flags_12 || some_other_conditions) {
> 				}
> 
> If you think that it is better, it's OK, just write your code like that. 
> And don't force it to everyone.
> 
No, I wouldn't say that that's better either, but that's also not how I
suggested cleaning reworking it. We have existing conventions for how
complex blocks are broken down in to more readable forms which you seem
to have issues grasping. My point is that you are purposely obfuscating
things, and therefore your entire rationale is suspect at best.

> For me, breaking the expression into variables is worse because:
> - adding/removing conditions must be done at 3 places (vs. my original 
> example, where it would be done only on 1 place)
> - when reading the conditions, your eyes must skip to two places (vs. my 
> original example, where you only read it at one place)
> 
> But everyone has different brain, so it may be that for you, the extra 
> variables are really more understandable. So write your code like that and 
> don't preach.
> 
This isn't a subjective thing as you are now trying to spin it. There are
existing conventions that the majority of kernel code follows and any of
your above obfuscated blocks are unlikely to show up in any code outside
of drivers/. How about actually reading through the coding style document
and existing code before attempting to cripple checkpatch.

You've also ignored everything that was stated about the reasons for why
we have this limit and why it is useful, instead focusing purely on the
fact that I've taken issue with your bogus examples that would never have
been applied in the first place.

If you simply wanted a way to get around the limit, then something like
Bart's patch is quite reasonable and I don't believe anyone has any
objections to it. This half-baked rationale for tossing it out completely
using examples that don't even show up in the kernel though is simply
nonsense. Perhaps if you spent half as much time auditing vendor patches
you would have some idea of why having these warnings is not just a nice
thing to have, but also the only sensible default.

  reply	other threads:[~2009-12-17 23:12 UTC|newest]

Thread overview: 48+ 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 22:26 ` Bartlomiej Zolnierkiewicz
2009-12-17  9:31   ` Américo Wang
2009-12-17 15:14     ` Linus Torvalds
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: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 22:33                 ` Krzysztof Halasa
2009-12-18 13:04         ` Jiri Kosina
2009-12-18 13:55           ` Bartlomiej Zolnierkiewicz
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  8:34   ` Krzysztof Halasa
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 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 15:12             ` [dm-devel] " Alasdair G Kergon
2009-12-18 16:58               ` Randy Dunlap
2009-12-18 17:12                 ` Mikulas Patocka
2009-12-18 22:36                   ` Krzysztof Halasa
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:52           ` kevin granade
2009-12-18 16:43             ` Mikulas Patocka
2009-12-18 16:50               ` Linus Torvalds
2009-12-18 17:09                 ` Mikulas Patocka
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 23:12     ` Paul Mundt [this message]
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=20091217231240.GA1421@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=torvalds@linux-foundation.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