]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: add check for spaces around logical AND operators
authorGabriel Marin <marin.gabriel@protonmail.com>
Thu, 3 Oct 2024 16:20:09 +0000 (19:20 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 21 Oct 2024 07:35:00 +0000 (09:35 +0200)
Closes #15144

lib/vtls/rustls.c
scripts/checksrc.pl

index c9409d12aa81ae846990edf8a703ab3a6e3fdf94..087ff423bd8c62926076994c85ee23696f5c5baa 100644 (file)
@@ -895,7 +895,7 @@ cr_connect_common(struct Curl_cfilter *cf,
     }
     if(0 == what) {
       CURL_TRC_CF(data, cf, "Curl_socket_check: %s would block",
-            wants_read&&wants_write ? "writing and reading" :
+            wants_read && wants_write ? "writing and reading" :
             wants_write ? "writing" : "reading");
       if(wants_write)
         connssl->io_need |= CURL_SSL_IO_NEED_SEND;
index 0f727e38b988ef495076ae00b73e516b84da6627..7075278de2f7ccfb2acc03cba068f8829ffb8494 100755 (executable)
@@ -80,6 +80,7 @@ my %warnings = (
     'LONGLINE'              => "Line longer than $max_column",
     'SPACEBEFORELABEL'      => 'labels not at the start of the line',
     'MULTISPACE'            => 'multiple spaces used when not suitable',
+    'NOSPACEAND'            => 'missing space around Logical AND operator',
     'NOSPACEC'              => 'missing space around ternary colon operator',
     'NOSPACEEQUALS'         => 'equals sign without preceding space',
     'NOSPACEQ'              => 'missing space around ternary question mark operator',
@@ -626,6 +627,20 @@ sub scanfile {
                       "space after open parenthesis");
         }
 
+        # check spaces before Logical AND operator
+        if($nostr =~ /^(.*)\w&&/i) {
+            checkwarn("NOSPACEAND",
+                      $line, length($1)+1, $file, $l,
+                      "missing space before Logical AND");
+        }
+
+        # check spaces after Logical AND operator
+        if($nostr =~ /^(.*&&)\w/i) {
+            checkwarn("NOSPACEAND",
+                      $line, length($1), $file, $l,
+                      "missing space after Logical AND");
+        }
+
         # check spaces before colon
         if($nostr =~ /^(.*[^']\?[^'].*)(\w|\)|\]|')\:/i) {
             my $m = $1;