From: Joe Perches <joe@perches.com>
To: Yury Norov <ynorov@caviumnetworks.com>,
Andy Whitcroft <apw@canonical.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: suppress false long-line warining
Date: Mon, 27 Nov 2017 21:04:24 -0800 [thread overview]
Message-ID: <1511845464.32426.94.camel@perches.com> (raw)
In-Reply-To: <20171128023938.19872-1-ynorov@caviumnetworks.com>
On Tue, 2017-11-28 at 05:39 +0300, Yury Norov wrote:
> For DOS-formatted patches, extra ^M symbol at the end of line
> increases overall line length by 1.
>
> It triggers unneeded warning if line is exactly 80 chars length.
> This patch fixes it.
It's may be simpler to just remove the \015 from the
input line
> Discovered in discussion to this patch:
> https://lkml.org/lkml/2017/11/25/24
>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> ---
> scripts/checkpatch.pl | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -59,6 +59,7 @@ my $conststructsfile = "$D/const_structs.checkpatch";
> my $typedefsfile = "";
> my $color = "auto";
> my $allow_c99_comments = 1;
> +my $is_dos_line;
>
> sub help {
> my ($exitcode) = @_;
> @@ -2731,7 +2732,9 @@ sub process {
> next if (!$hunk_line || $line =~ /^-/);
>
> #trailing whitespace
> + $is_dos_line = 0;
> if ($line =~ /^\+.*\015$/) {
Maybe:
$line =~ /\015$//;
$length--;
and nothing else
> + $is_dos_line = 1 if (!$fix_inplace);
> my $herevet = "$here\n" . cat_vet($rawline) . "\n";
> if (ERROR("DOS_LINE_ENDINGS",
> "DOS line endings\n" . $herevet) &&
> @@ -2884,7 +2887,12 @@ sub process {
> # if LONG_LINE is ignored, the other 2 types are also ignored
> #
>
> - if ($line =~ /^\+/ && $length > $max_line_length) {
> + # If DOS line detected, additional ^M symbol at the end of
> + # line increases line length, so increase max_line_length
> + # accordingly.
> + my $__max_line_length = $max_line_length + $is_dos_line;
> +
> + if ($line =~ /^\+/ && $length > $__max_line_length) {
> my $msg_type = "LONG_LINE";
>
> # Check the allowed long line types first
> @@ -2892,7 +2900,7 @@ sub process {
> # logging functions that end in a string that starts
> # before $max_line_length
> if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ &&
> - length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
> + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) {
> $msg_type = "";
>
> # lines with only strings (w/ possible termination)
> @@ -2910,12 +2918,12 @@ sub process {
>
> # a comment starts before $max_line_length
> } elsif ($line =~ /($;[\s$;]*)$/ &&
> - length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
> + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) {
> $msg_type = "LONG_LINE_COMMENT"
>
> # a 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) {
> + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) {
> $msg_type = "LONG_LINE_STRING"
> }
>
prev parent reply other threads:[~2017-11-28 5:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 2:39 Yury Norov
2017-11-28 5:04 ` Joe Perches [this message]
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=1511845464.32426.94.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ynorov@caviumnetworks.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 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®