All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
@ 2013-10-07 19:18 Josh Triplett
  2013-10-07 19:28 ` Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Josh Triplett @ 2013-10-07 19:18 UTC (permalink / raw)
  To: torvalds, gregkh, Andy Whitcroft, Joe Perches, linux-kernel

The 80-character limit is not a hard-and-fast rule, nor should it be
applied blindly by people running checkpatch and fixing its warnings.
Sometimes it's better to violate the 80-character "limit" in the name of
readability, and when it isn't, it's often better to refactor into a
function or otherwise restructure the code rather than just finding
increasingly awkward places to break lines.

Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
Anyone wanting to use checkpatch to check for this can easily enough
enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
part of the default warnings.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---

 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 47016c3..ed16a68 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2017,8 +2017,8 @@ sub process {
 		    $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
 		    $length > $max_line_length)
 		{
-			WARN("LONG_LINE",
-			     "line over $max_line_length characters\n" . $herecurr);
+			CHK("LONG_LINE",
+			    "line over $max_line_length characters\n" . $herecurr);
 		}
 
 # Check for user-visible strings broken across lines, which breaks the ability
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:18 [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only Josh Triplett
@ 2013-10-07 19:28 ` Joe Perches
  2013-10-07 19:34   ` Josh Triplett
  2013-10-07 19:50 ` Richard Weinberger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Joe Perches @ 2013-10-07 19:28 UTC (permalink / raw)
  To: Josh Triplett; +Cc: torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, 2013-10-07 at 12:18 -0700, Josh Triplett wrote:
> The 80-character limit is not a hard-and-fast rule, nor should it be
> applied blindly by people running checkpatch and fixing its warnings.
> Sometimes it's better to violate the 80-character "limit" in the name of
> readability, and when it isn't, it's often better to refactor into a
> function or otherwise restructure the code rather than just finding
> increasingly awkward places to break lines.
> 
> Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> Anyone wanting to use checkpatch to check for this can easily enough
> enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> part of the default warnings.

I don't agree with this.

CodingStyle says:
----------------------
The limit on the length of lines is 80 columns and this is a strongly
preferred limit.
----------------------

People should be encouraged to use 80 column lines and as well
should learn to ignore messages they don't agree with.

If people are using checkpatch prior to any scripted git am,
then just as easily they could add --ignore=LONG_LINE.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:28 ` Joe Perches
@ 2013-10-07 19:34   ` Josh Triplett
  2013-10-07 19:38     ` Joe Perches
  2013-10-07 21:23     ` Al Viro
  0 siblings, 2 replies; 11+ messages in thread
From: Josh Triplett @ 2013-10-07 19:34 UTC (permalink / raw)
  To: Joe Perches; +Cc: torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, Oct 07, 2013 at 12:28:26PM -0700, Joe Perches wrote:
> On Mon, 2013-10-07 at 12:18 -0700, Josh Triplett wrote:
> > The 80-character limit is not a hard-and-fast rule, nor should it be
> > applied blindly by people running checkpatch and fixing its warnings.
> > Sometimes it's better to violate the 80-character "limit" in the name of
> > readability, and when it isn't, it's often better to refactor into a
> > function or otherwise restructure the code rather than just finding
> > increasingly awkward places to break lines.
> > 
> > Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> > Anyone wanting to use checkpatch to check for this can easily enough
> > enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> > part of the default warnings.
> 
> I don't agree with this.
> 
> CodingStyle says:
> ----------------------
> The limit on the length of lines is 80 columns and this is a strongly
> preferred limit.
> ----------------------

Which is the subject of much controversy and extensive discussion, and
the consensus on the list (including by many maintainers) frequently
differs from that.

> People should be encouraged to use 80 column lines and as well
> should learn to ignore messages they don't agree with.

I've seen far more examples of the 80-column limit making code less
readable rather than more.  It's only really helpful when it forces code
restructuring, *not* when it just forces an arbitrary line break.

> If people are using checkpatch prior to any scripted git am,
> then just as easily they could add --ignore=LONG_LINE.

Which random folks running checkpatch on staging drivers and trying to
help don't necessarily know to do.  The defaults should cater to the
primary use case, and the 80-column limit is not something to apply
blindly.  It falls in the same category as some of the warnings the
kernel emits with W=2 or so: sometimes helpful, often noise.

- Josh Triplett

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:34   ` Josh Triplett
@ 2013-10-07 19:38     ` Joe Perches
  2013-10-08  2:08       ` Josh Triplett
  2013-10-07 21:23     ` Al Viro
  1 sibling, 1 reply; 11+ messages in thread
From: Joe Perches @ 2013-10-07 19:38 UTC (permalink / raw)
  To: Josh Triplett; +Cc: torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, 2013-10-07 at 12:34 -0700, Josh Triplett wrote:
> On Mon, Oct 07, 2013 at 12:28:26PM -0700, Joe Perches wrote:
> > On Mon, 2013-10-07 at 12:18 -0700, Josh Triplett wrote:
> > > The 80-character limit is not a hard-and-fast rule, nor should it be
> > > applied blindly by people running checkpatch and fixing its warnings.
> > > Sometimes it's better to violate the 80-character "limit" in the name of
> > > readability, and when it isn't, it's often better to refactor into a
> > > function or otherwise restructure the code rather than just finding
> > > increasingly awkward places to break lines.
> > > 
> > > Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> > > Anyone wanting to use checkpatch to check for this can easily enough
> > > enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> > > part of the default warnings.
> > 
> > I don't agree with this.
> > 
> > CodingStyle says:
> > ----------------------
> > The limit on the length of lines is 80 columns and this is a strongly
> > preferred limit.
> > ----------------------
> 
> Which is the subject of much controversy and extensive discussion, and
> the consensus on the list (including by many maintainers) frequently
> differs from that.

Been there, had that discussion.
https://lkml.org/lkml/2009/12/18/3

I'm not applying/acking this.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:18 [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only Josh Triplett
  2013-10-07 19:28 ` Joe Perches
@ 2013-10-07 19:50 ` Richard Weinberger
  2013-10-07 21:40 ` Andi Kleen
  2013-10-08  4:13 ` Greg KH
  3 siblings, 0 replies; 11+ messages in thread
From: Richard Weinberger @ 2013-10-07 19:50 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Linus Torvalds, gregkh, Andy Whitcroft, Joe Perches, LKML

On Mon, Oct 7, 2013 at 9:18 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> The 80-character limit is not a hard-and-fast rule, nor should it be
> applied blindly by people running checkpatch and fixing its warnings.
> Sometimes it's better to violate the 80-character "limit" in the name of
> readability, and when it isn't, it's often better to refactor into a
> function or otherwise restructure the code rather than just finding
> increasingly awkward places to break lines.
>
> Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> Anyone wanting to use checkpatch to check for this can easily enough
> enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> part of the default warnings.
>
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>

As I'm not a huge fan of the 80-character limit,

Acked-by: Richard Weinberger <richard@nod.at>

> ---
>
>  scripts/checkpatch.pl | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 47016c3..ed16a68 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2017,8 +2017,8 @@ sub process {
>                     $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
>                     $length > $max_line_length)
>                 {
> -                       WARN("LONG_LINE",
> -                            "line over $max_line_length characters\n" . $herecurr);
> +                       CHK("LONG_LINE",
> +                           "line over $max_line_length characters\n" . $herecurr);
>                 }
>
>  # Check for user-visible strings broken across lines, which breaks the ability
> --
> 1.8.4.rc3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:34   ` Josh Triplett
  2013-10-07 19:38     ` Joe Perches
@ 2013-10-07 21:23     ` Al Viro
  2013-10-07 21:33       ` Joe Perches
  1 sibling, 1 reply; 11+ messages in thread
From: Al Viro @ 2013-10-07 21:23 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Joe Perches, torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, Oct 07, 2013 at 12:34:33PM -0700, Josh Triplett wrote:

> I've seen far more examples of the 80-column limit making code less
> readable rather than more.  It's only really helpful when it forces code
> restructuring, *not* when it just forces an arbitrary line break.

So teach that piece of crap to complain about fucked-in-head line breaks like
							ret_val =
							    leaf_shift_left(tb,
									    tb->
									    lnum
									    [0],
									    tb->
									    lbytes
									    -
									    1);
in addition to obscenely long lines (and yes, it is a real-world example).

The one and only point of such tools is to help locating the crappy code.
And that's the only sane criterion for evaluating new "stylistic rules" -
does that particular heuristic catch enough shitty places or not?

_Anything_ can be obfuscated to the point where warnings are not produced
anymore...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 21:23     ` Al Viro
@ 2013-10-07 21:33       ` Joe Perches
  2013-10-07 21:41         ` Joe Perches
  0 siblings, 1 reply; 11+ messages in thread
From: Joe Perches @ 2013-10-07 21:33 UTC (permalink / raw)
  To: Al Viro; +Cc: Josh Triplett, torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, 2013-10-07 at 22:23 +0100, Al Viro wrote:
> On Mon, Oct 07, 2013 at 12:34:33PM -0700, Josh Triplett wrote:
> 
> > I've seen far more examples of the 80-column limit making code less
> > readable rather than more.  It's only really helpful when it forces code
> > restructuring, *not* when it just forces an arbitrary line break.
> 
> So teach that piece of crap to complain about fucked-in-head line breaks like
> 							ret_val =
> 							    leaf_shift_left(tb,
> 									    tb->
> 									    lnum
> 									    [0],
> 									    tb->
> 									    lbytes
> 									    -
> 									    1);
> in addition to obscenely long lines (and yes, it is a real-world example).

Yup, that's pretty ugly.

It was autogenerated and introduced when Linus
rather arbitrarily lindented the reiserfs code.

btw: I think lindent should be removed from scripts/
http://lkml.org/lkml/2013/2/11/390

I believe reiserfs was originally set to a 132
column width maximum.

commit bd4c625c061c2a38568d0add3478f59172455159
Author: Linus Torvalds <torvalds@g5.osdl.org>
Date:   Tue Jul 12 20:21:28 2005 -0700

    reiserfs: run scripts/Lindent on reiserfs code
    
    This was a pure indentation change, using:
    
        scripts/Lindent fs/reiserfs/*.c include/linux/reiserfs_*.h



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:18 [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only Josh Triplett
  2013-10-07 19:28 ` Joe Perches
  2013-10-07 19:50 ` Richard Weinberger
@ 2013-10-07 21:40 ` Andi Kleen
  2013-10-08  4:13 ` Greg KH
  3 siblings, 0 replies; 11+ messages in thread
From: Andi Kleen @ 2013-10-07 21:40 UTC (permalink / raw)
  To: Josh Triplett; +Cc: torvalds, gregkh, Andy Whitcroft, Joe Perches, linux-kernel

Josh Triplett <josh@joshtriplett.org> writes:

> The 80-character limit is not a hard-and-fast rule, nor should it be
> applied blindly by people running checkpatch and fixing its warnings.
> Sometimes it's better to violate the 80-character "limit" in the name of
> readability, and when it isn't, it's often better to refactor into a
> function or otherwise restructure the code rather than just finding
> increasingly awkward places to break lines.

Yes please!

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 21:33       ` Joe Perches
@ 2013-10-07 21:41         ` Joe Perches
  0 siblings, 0 replies; 11+ messages in thread
From: Joe Perches @ 2013-10-07 21:41 UTC (permalink / raw)
  To: Al Viro; +Cc: Josh Triplett, torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, 2013-10-07 at 14:33 -0700, Joe Perches wrote:
> On Mon, 2013-10-07 at 22:23 +0100, Al Viro wrote:
> > On Mon, Oct 07, 2013 at 12:34:33PM -0700, Josh Triplett wrote:
> > 
> > > I've seen far more examples of the 80-column limit making code less
> > > readable rather than more.  It's only really helpful when it forces code
> > > restructuring, *not* when it just forces an arbitrary line break.
> > 
> > So teach that piece of crap to complain about fucked-in-head line breaks like
> > 							ret_val =
> > 							    leaf_shift_left(tb,
> > 									    tb->
> > 									    lnum
> > 									    [0],
> > 									    tb->
> > 									    lbytes
> > 									    -
> > 									    1);
> > in addition to obscenely long lines (and yes, it is a real-world example).

btw: checkpatch does suggest refactoring when there are
6+ indent tabs with an if/while/for/do/switch statement.
so it already does bleat around there.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:38     ` Joe Perches
@ 2013-10-08  2:08       ` Josh Triplett
  0 siblings, 0 replies; 11+ messages in thread
From: Josh Triplett @ 2013-10-08  2:08 UTC (permalink / raw)
  To: Joe Perches; +Cc: torvalds, gregkh, Andy Whitcroft, linux-kernel

On Mon, Oct 07, 2013 at 12:38:20PM -0700, Joe Perches wrote:
> On Mon, 2013-10-07 at 12:34 -0700, Josh Triplett wrote:
> > On Mon, Oct 07, 2013 at 12:28:26PM -0700, Joe Perches wrote:
> > > On Mon, 2013-10-07 at 12:18 -0700, Josh Triplett wrote:
> > > > The 80-character limit is not a hard-and-fast rule, nor should it be
> > > > applied blindly by people running checkpatch and fixing its warnings.
> > > > Sometimes it's better to violate the 80-character "limit" in the name of
> > > > readability, and when it isn't, it's often better to refactor into a
> > > > function or otherwise restructure the code rather than just finding
> > > > increasingly awkward places to break lines.
> > > > 
> > > > Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> > > > Anyone wanting to use checkpatch to check for this can easily enough
> > > > enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> > > > part of the default warnings.
> > > 
> > > I don't agree with this.
> > > 
> > > CodingStyle says:
> > > ----------------------
> > > The limit on the length of lines is 80 columns and this is a strongly
> > > preferred limit.
> > > ----------------------
> > 
> > Which is the subject of much controversy and extensive discussion, and
> > the consensus on the list (including by many maintainers) frequently
> > differs from that.
> 
> Been there, had that discussion.
> https://lkml.org/lkml/2009/12/18/3

I see many positive responses in that thread, from Linus and others, and
very little negativity (mostly quibbles about implementation, not about
the overall proposal).  What was the problem?

In particular:
> I'll happily remove the checkpatch.pl limit entirely, and ask people to
> try to use common sense, though.

Between that and the positive responses in this thread, I'd love to see
your proposed patch revived.

- Josh Triplett

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only
  2013-10-07 19:18 [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only Josh Triplett
                   ` (2 preceding siblings ...)
  2013-10-07 21:40 ` Andi Kleen
@ 2013-10-08  4:13 ` Greg KH
  3 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2013-10-08  4:13 UTC (permalink / raw)
  To: Josh Triplett; +Cc: torvalds, Andy Whitcroft, Joe Perches, linux-kernel

On Mon, Oct 07, 2013 at 12:18:43PM -0700, Josh Triplett wrote:
> The 80-character limit is not a hard-and-fast rule, nor should it be
> applied blindly by people running checkpatch and fixing its warnings.
> Sometimes it's better to violate the 80-character "limit" in the name of
> readability, and when it isn't, it's often better to refactor into a
> function or otherwise restructure the code rather than just finding
> increasingly awkward places to break lines.
> 
> Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead.
> Anyone wanting to use checkpatch to check for this can easily enough
> enable --strict or turn on LONG_LINE explicitly, but it shouldn't be
> part of the default warnings.
> 
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-08  4:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-07 19:18 [RFC PATCH] checkpatch: Make the 80-character limit a --strict check only Josh Triplett
2013-10-07 19:28 ` Joe Perches
2013-10-07 19:34   ` Josh Triplett
2013-10-07 19:38     ` Joe Perches
2013-10-08  2:08       ` Josh Triplett
2013-10-07 21:23     ` Al Viro
2013-10-07 21:33       ` Joe Perches
2013-10-07 21:41         ` Joe Perches
2013-10-07 19:50 ` Richard Weinberger
2013-10-07 21:40 ` Andi Kleen
2013-10-08  4:13 ` Greg KH

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.