mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>, Andy Whitcroft <apw@canonical.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: Checking for space before ending comment tag
Date: Sat, 19 Mar 2022 19:30:22 -0700	[thread overview]
Message-ID: <86bce3b4176ac83c4d4c82c38bf2e8eac5983b1c.camel@perches.com> (raw)
In-Reply-To: <b42be7ee3ed3a2356b7c5ddad545e12d5e7a0ee7.camel@perches.com>

Maybe this is better as it can fix them too.

---
 scripts/checkpatch.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 577e029987011..70afa4ff2addf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3868,6 +3868,22 @@ sub process {
 			}
 		}
 
+# Single line comment style - warn when '/*comment */' or '/* comment*/'
+		if ($line =~ /^\+.*$;/ &&
+		    $rawline =~ m@/\*.+\*/@ &&
+		    (($rawline =~ m@/\* @  && $rawline =~ m@\w\*/@) ||
+		     ($rawline =~ m@/\*\w@ && $rawline =~ m@ \*/@))) {
+			if (WARN("COMMENT_STYLE",
+				 "Single line comments should use a space after /* and before */\n" . $herecurr) &&
+			    $fix) {
+				$rawline =~ m@/\*.+\*/@;
+				my $comment = substr($rawline, $-[0], $+[0] - $-[0]);
+				my $newcomment = trim(substr($comment, 2, -2));
+				$fixed[$fixlinenr] =~
+				    s@\Q$comment\E@/\* $newcomment \*/@;
+			}
+		}
+
 # Block comment styles
 # Networking with an initial /*
 		if ($realfile =~ m@^(drivers/net/|net/)@ &&


      reply	other threads:[~2022-03-20  2:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fb2ab099-aefa-6a84-5c62-f0c87eca2725@molgen.mpg.de>
2022-03-19  8:42 ` Joe Perches
2022-03-20  2:30   ` 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=86bce3b4176ac83c4d4c82c38bf2e8eac5983b1c.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    /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®