mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andres Salomon <dilinger@queued.net>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andy Whitcroft <apw@shadowen.org>,
	mingo@elte.hu, rdunlap@xenotime.net, jschopp@austin.ibm.com
Subject: [PATCH] checkpatch: update the 80-char-line check to allow for long strings
Date: Wed, 14 May 2008 00:53:25 -0400	[thread overview]
Message-ID: <20080514005325.765178fc@ephemeral> (raw)

19:29 * dilinger sends his patch to lkml for a proper flaming
19:32  Quozl> dilinger: it's called "patch hardening"?  ;-}  the heat
              of the flames makes the patch stronger.

I've wasted too much time massaging printk strings in order to satisfy
checkpatch.pl.  Comments on this?





From: Andres Salomon <dilinger@debian.org>


Checkpatch.pl is pretty strict in its lines-must-be-less-than-80-chars
check.  I consider this a good thing in most scenarios; however,
when it comes to strings, I don't consider the following to be readable:

       printk(KERN_WARNING
                       "one two three "
                       "fooooooooooooooooooooooooooooooooooooooooooooooo\n");

CodingStyle backs me up on this (if I'm interpreting that section clearly).
Ingo[0] has also pointed out why this might be a bad thing as well.

This patch is an attempt to make checkpatch.pl more useful.  Folks ignore
long string warnings[1], which is bad form; we don't _want_ people getting
used to ignoring checkpatch.pl warnings any more than we want people
getting used to ignoring compiler warnings.

The patch updates checkpatch.pl to ignore lines that are > 80 chars
if they contain only (quoted) strings and perhaps some additional stuff
at the end.  For example, the following no longer has warnings emitted:

+ printk(KERN_WARNING
+                       "one two three fooooooooooooooooooooooooooooooooooooooooooooooo\n");

+       printk(KERN_WARNING
+                       "one two three fooooooooooooooooooooooooooooooooooooooooo\n",
+                       xyz);

However, the following still triggers checkpatch.pl warnings:

+ printk(KERN_WARNING "one two three fooooooooooooooooooooooooooooooooooooooooooooooo\n");

+       printk(KERN_WARNING
+                       "one two three foooooooooooooooooooooooooooooooooooooo\n", xyz);

I'm sure it's possible to fool the check, but we're not trying to guard
against malicious patch authors.

[0] http://thread.gmane.org/gmane.linux.kernel/679732/focus=679760
[1] http://lists.laptop.org/pipermail/devel/2008-May/014121.html

Signed-off-by: Andres Salomon <dilinger@debian.org>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b6bbbcd..00f3d05 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1117,7 +1117,7 @@ sub process {
 			ERROR("trailing whitespace\n" . $herevet);
 		}
 #80 column limit
-		if ($line =~ /^\+/ && !($prevrawline=~/\/\*\*/) && $length > 80) {
+		if ($line =~ /^\+/ && !($prevrawline=~/\/\*\*/) && !($line =~ /^\+\s*"/ && $line =~ /"[);,\s]*$/) && $length > 80) {
 			WARN("line over 80 characters\n" . $herecurr);
 		}
 
-- 
1.5.5.1


             reply	other threads:[~2008-05-14  4:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-14  4:53 Andres Salomon [this message]
2008-05-14  7:49 ` Peter Zijlstra
2008-05-14 14:49   ` Andres Salomon
2008-05-14 15:59     ` Andy Whitcroft
2008-05-14 16:23       ` Andres Salomon

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=20080514005325.765178fc@ephemeral \
    --to=dilinger@queued.net \
    --cc=akpm@linux-foundation.org \
    --cc=apw@shadowen.org \
    --cc=jschopp@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rdunlap@xenotime.net \
    /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®