public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	oleg.drokin@intel.com, devel@driverdev.osuosl.org,
	gregkh@linuxfoundation.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org, HPDD-discuss@ml01.01.org,
	lustre-deve@lists.lustre.org,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Mike Shuey <shuey@purdue.edu>
Subject: Re: [PATCH] checkpatch: Categorize some long line length checks
Date: Sat, 23 May 2015 11:32:18 +0000	[thread overview]
Message-ID: <alpine.DEB.2.10.1505231331050.2554@hadrien> (raw)
In-Reply-To: <1432362494.29657.40.camel@perches.com>



On Fri, 22 May 2015, Joe Perches wrote:

> Many lines of code extend beyond the maximum line length.
> Some of these are possibly justified by use type.
>
> For instance:
>
> structure definitions where comments are added per member like
>
> struct foo {
> 	type member;		/* some long description */

I'm not super fond of the comment one.  Perhaps people could express
themselves more concisely, or put the details elsewhere?

julia

> }
>
> And lines that don't fit the typical logging message style
> where a string constant is used like:
>
> 	SOME_MACRO(args, "Some long string");
>
> Categorize these long line types so that checkpatch can use
> a command-line --ignore=<type> option to avoid emitting some
> long line warnings.
>
> Comment the code a bit better too.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 44 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 89b1df4..99ce3f4 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2510,16 +2510,50 @@ sub process {
>  # check we are in a valid source file if not then ignore this hunk
>  		next if ($realfile !~ /\.(h|c|s|S|pl|sh|dtsi|dts)$/);
>
> -#line length limit
> -		if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
> -		    $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
> -		    !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?$String\s*(?:|,|\)\s*;)\s*$/ ||
> -		      $line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
> -		      $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) &&
> -		    $length > $max_line_length)
> -		{
> -			WARN("LONG_LINE",
> -			     "line over $max_line_length characters\n" . $herecurr);
> +# line length limit (with some exclusions)
> +#
> +# There are 3 different line length message types:
> +# LONG_LINE_COMMENT	a comment starts before but extends beyond length
> +# LONG_LINE_STRING	a string starts before but extends beyond length
> +# LONG_LINE		all other lines longer than $max_line_length
> +#
> +# if LONG_LINE is ignored, the other 2 types are also ignored
> +#
> +# LONG_LINE has a few types of lines that may extend beyong $max_line_length
> +#	kernel-doc arguments
> +#	logging functions like pr_info that end in a string
> +#	lines with a single string
> +#	#defines that are a single string
> +
> +		if ($length > $max_line_length) {
> +			my $msg_type = "";
> +
> +			# comment starts before $max_line_length
> +			if ($line =~ /([\s$;]+)$/ &&
> +			    length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
> +				$msg_type = "LONG_LINE_COMMENT"
> +
> +			# quoted string starts before $max_line_length
> +			} elsif ($sline =~ /\s*($String(?:\s*(?:\\|,\s*|\)\s*;\s*))?)$/ &&
> +				 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
> +				$msg_type = "LONG_LINE_STRING"
> +
> +			# general long longs
> +				# exclude kernel-doc argument lines
> +			} elsif ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
> +				 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
> +				# exclude logging functions that end in a string
> +				 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?$String\s*(?:|,|\)\s*;)\s*$/ ||
> +				# exclude lines with only strings
> +				   $line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
> +				# exclude #defines with only strings
> +				   $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/)) {
> +				$msg_type = "LONG_LINE";
> +			}
> +			if ($msg_type ne "" && show_type("LONG_LINE")) {
> +				WARN($msg_type,
> +				     "line over $max_line_length characters\n" . $herecurr);
> +			}
>  		}
>
>  # check for adding lines without a newline.
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2015-05-23 11:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21 19:50 [PATCH v4 00/13] staging: lustre: lnet: code cleanups Mike Shuey
2015-05-21 19:50 ` [PATCH v4 01/13] staging: lustre: lnet: lnet: code cleanups - variable declarations Mike Shuey
2015-05-21 19:50 ` [PATCH v4 02/13] staging: lustre: lnet: dead code - remove lnet_fini_locks Mike Shuey
2015-05-21 19:50 ` [PATCH v4 03/13] staging: lustre: lnet: dead code - remove LNetSetAsync Mike Shuey
2015-05-21 19:50 ` [PATCH v4 04/13] staging: lustre: lnet: lnet: Module is LNet, not Portals Mike Shuey
2015-05-21 19:50 ` [PATCH v4 05/13] staging: lustre: lnet: o2iblnd: code cleanup - align whitespace Mike Shuey
2015-05-22 13:03   ` Dan Carpenter
2015-05-21 19:50 ` [PATCH v4 08/13] staging: lustre: lnet: remove LNET_MUTEX_LOCK macro Mike Shuey
2015-05-21 19:50 ` [PATCH v4 09/13] staging: lustre: lnet: lnet: remove dead code, fix checkpatch.pl issue Mike Shuey
2015-05-21 19:50 ` [PATCH v4 10/13] staging: lustre: lnet: lnet: checkpatch.pl fixes Mike Shuey
2015-05-21 21:00   ` Joe Perches
2015-05-21 21:29     ` Julia Lawall
     [not found]       ` <CABqvwjuKypiacf3336j-q450FGKaO4wh0Ld7PF8MGz0VPsYBbw@mail.gmail.com>
2015-05-22  2:46         ` Joe Perches
2015-05-22  5:06         ` Julia Lawall
2015-05-22  8:08           ` Drokin, Oleg
2015-05-22 15:42             ` Joe Perches
2015-05-22 21:16               ` Drokin, Oleg
2015-05-22 23:57                 ` Joe Perches
2015-05-23  0:07                   ` Drokin, Oleg
2015-05-23  0:18                     ` Joe Perches
2015-05-23  0:25                       ` Drokin, Oleg
2015-05-23  0:36                         ` Joe Perches
2015-05-23  3:13                           ` [HPDD-discuss] " Patrick Farrell
     [not found]     ` <CABqvwjs=S1VrCHe7M4JnDikGBVN3yqjNMrtSA=UvftGmxSasRQ@mail.gmail.com>
2015-05-22  3:06       ` Joe Perches
2015-05-22  8:04       ` Drokin, Oleg
2015-05-22 10:00         ` Julia Lawall
2015-05-23  6:28     ` [PATCH] checkpatch: Categorize some long line length checks Joe Perches
2015-05-23 11:32       ` Julia Lawall [this message]
2015-05-23 17:26         ` Joe Perches
2015-05-23 18:07           ` Dan Carpenter
2015-05-23 18:13             ` Joe Perches
2015-05-23 18:21               ` Dan Carpenter
2015-05-21 19:50 ` [PATCH v4 11/13] staging: lnet: o2iblnd: checkpatch.pl fixes Mike Shuey
2015-05-22 10:49   ` Dan Carpenter
2015-05-21 19:50 ` [PATCH v4 12/13] staging: lustre: lnet: socklnd: checkpatch.pl cleanups Mike Shuey
2015-05-21 19:50 ` [PATCH v4 13/13] staging: lustre: lnet: selftest: checkpatch.pl fixes Mike Shuey
2015-05-21 19:50 ` [PATCH 01/13] staging: lustre: lnet: lnet: code cleanups - variable declarations Mike Shuey
2015-05-21 19:50 ` [PATCH 02/13] staging: lustre: lnet: dead code - remove lnet_fini_locks Mike Shuey
2015-05-21 19:50 ` [PATCH 03/13] staging: lustre: lnet: dead code - remove LNetSetAsync Mike Shuey
2015-05-21 19:50 ` [PATCH 04/13] staging: lustre: lnet: lnet: Module is LNet, not Portals Mike Shuey
2015-05-21 19:50 ` [PATCH 05/13] staging: lustre: lnet: o2iblnd: code cleanup - align whitespace Mike Shuey
2015-05-21 19:50 ` [PATCH 08/13] staging: lustre: lnet: remove LNET_MUTEX_LOCK macro Mike Shuey
2015-05-21 19:50 ` [PATCH 09/13] staging: lustre: lnet: lnet: remove dead code, fix checkpatch.pl issue Mike Shuey
2015-05-21 19:50 ` [PATCH 10/13] staging: lustre: lnet: lnet: checkpatch.pl fixes Mike Shuey
2015-05-21 19:50 ` [PATCH 11/13] staging: lnet: o2iblnd: " Mike Shuey
2015-05-21 19:50 ` [PATCH 12/13] staging: lustre: lnet: socklnd: checkpatch.pl cleanups Mike Shuey
2015-05-21 19:50 ` [PATCH 13/13] staging: lustre: lnet: selftest: checkpatch.pl fixes Mike Shuey
2015-05-22 10:55   ` Dan Carpenter
2015-05-22  9:21 ` [PATCH v4 00/13] staging: lustre: lnet: code cleanups Dan Carpenter
     [not found]   ` <CABqvwjsJXJYciMDHqy9vEdL6dGLhx3+Pi0_ro6192Z5SGR9Q_w@mail.gmail.com>
2015-05-23 10:14     ` Dan Carpenter
2015-05-23 12:09       ` Michael Shuey
2015-05-23 12:51         ` Sudip Mukherjee
2015-05-23 14:05           ` Michael Shuey
2015-05-31  2:24             ` Greg KH

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=alpine.DEB.2.10.1505231331050.2554@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-deve@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    --cc=shuey@purdue.edu \
    /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