Skip to contentSkip to conversation

checkpatch: Don't count URLs for "line too long"

PATCH In review Kees Cook 2 participants 4 messages Sep 27, 2022 Checkpatch

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 checkpatch: Don't count URLs for "line too long"

URLs (not in a Link: field) should be ignored for "line too long" warnings. Allow any line containing "https://" or "http://".

Cc Andy Whitcroft <[email protected]>
Cc Joe Perches <[email protected]>
Cc Dwaipayan Ray <[email protected]>
Cc Lukas Bulwahn <[email protected]>
---
 scripts/checkpatch.pl | 2 ++
 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
index 79e759aac543..d4dec90673b7 100755
@@ -3175,6 +3175,8 @@ sub process {
 					# file delta changes
 		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
 					# filename then :
+		      $line =~ /https?:\/\// ||
+					# URLs
 		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
 					# A Fixes: or Link: line or signature tag line
 		      $commit_log_possible_stack_dump)) {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 2 lines · Kees Cook

URLs (not in a Link: field) should be ignored for "line too long" warnings. Allow any line containing "https://" or "http://".

More generally, this should be for any URI

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3182

Quoted 9 lines
scripts/checkpatch.pl +2 -0
@@ -3175,6 +3175,8 @@ sub process {
 					# file delta changes
 		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
 					# filename then :
+		      $line =~ /https?:\/\// ||
+					# URLs
 		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
 					# A Fixes: or Link: line or signature tag line
 		      $commit_log_possible_stack_dump)) {

And I don't recollect why this wasn't applied, but I think it's a rather better, more complete, patch:

https://lore.kernel.org/lkml/[email protected]/

I believe I did ack it and forward it to Andrew Morton, but I don't see it on a lore list.

author
#2 lore raw
Quoted 21 lines · Joe Perches
Quoted 2 lines · Kees Cook

URLs (not in a Link: field) should be ignored for "line too long" warnings. Allow any line containing "https://" or "http://".

More generally, this should be for any URI

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3182

Quoted 9 lines
scripts/checkpatch.pl +2 -0
@@ -3175,6 +3175,8 @@ sub process {
 					# file delta changes
 		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
 					# filename then :
+		      $line =~ /https?:\/\// ||
+					# URLs
 		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
 					# A Fixes: or Link: line or signature tag line
 		      $commit_log_possible_stack_dump)) {

And I don't recollect why this wasn't applied, but I think it's a rather better, more complete, patch:

Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/

I believe I did ack it and forward it to Andrew Morton, but I don't see it on a lore list.

Many patches have internal references in the commit log (that aren't appropriate for "Link:") like:

[1] https://some.domain/path/

It seems more flexible to just ignore lines with "http" in it...

-Kees

Signature · 1 line
Kees Cook
maintainer
#3 lore raw
Quoted 27 lines · Kees Cook
Quoted 21 lines · Joe Perches
Quoted 2 lines · Kees Cook

URLs (not in a Link: field) should be ignored for "line too long" warnings. Allow any line containing "https://" or "http://".

More generally, this should be for any URI

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3182

Quoted 9 lines
scripts/checkpatch.pl +2 -0
@@ -3175,6 +3175,8 @@ sub process {
 					# file delta changes
 		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
 					# filename then :
+		      $line =~ /https?:\/\// ||
+					# URLs
 		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
 					# A Fixes: or Link: line or signature tag line
 		      $commit_log_possible_stack_dump)) {

And I don't recollect why this wasn't applied, but I think it's a rather better, more complete, patch:

Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/

I believe I did ack it and forward it to Andrew Morton, but I don't see it on a lore list.

Quoted 6 lines

Many patches have internal references in the commit log (that aren't appropriate for "Link:") like:

[1] https://some.domain/path/

It seems more flexible to just ignore lines with "http" in it...

URLs vs URIs which can have multiple forms.

Take a look at the results of this grep:

$ git log -1000000 --format=email --no-merges --grep='://' | grep '://' | \
  grep -v -P 'https?://' | grep -P -oh '\b\w+://' | \
  sort | uniq -c | sort -rn
    422 git://
     46 ftp://
     15 file://
     10 smb://
      5 c://
      3 usbip://
      2 svn://
      2 rsync://
      2 pvr://
      1 ttp://
      1 systemd://
      1 server://
      1 radio://
      1 nbd://
      1 irc://
      1 intel_bts://
      1 htp://
      1 40176://

The more inclusve search pattern finds many uses of git:// and ftp:// (and probably a few typos too)

Assuming the URI scheme uses ://, it's perhaps reasonable to change the suggested search in Aditya's patch from

+ if ($line =~ /^\s*([a-z][\w\.\+\-]*:\/\/\S+)/i) {

to maybe something like this so the URI's use of :// is more obvious

+ if ($line =~ m@^.*\b([a-z][\w\.\+\-]*://\S+)@i) {