]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc.pl: detect assign followed by more than one space
authorDaniel Stenberg <daniel@haxx.se>
Wed, 5 Nov 2025 13:40:18 +0000 (14:40 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 5 Nov 2025 14:18:28 +0000 (15:18 +0100)
And fix some code previously doing this.

Closes #19375

lib/cf-h2-proxy.c
scripts/checksrc.pl
tests/libtest/lib557.c
tests/server/tftpd.c
tests/unit/unit1303.c

index f9bd827374fa33c2ceb53a96e2af7075ca7c4fe3..b0638c6642879ded8e891352d61a10d10404defd 100644 (file)
@@ -99,9 +99,9 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,
   if(result)
     return result;
 
-  ts->authority = /* host:port with IPv6 support */
-    curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
-                  ipv6_ip ? "]" : "", port);
+  /* host:port with IPv6 support */
+  ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
+                                ipv6_ip ? "]" : "", port);
   if(!ts->authority)
     return CURLE_OUT_OF_MEMORY;
 
index 7059d68575006d62abe8950a0ba73962ad071527..5dcad3e31526213a6bd58ddee6c28ad1db0fe2d2 100755 (executable)
@@ -131,6 +131,7 @@ my %warnings = (
     'DOBRACE'               => 'A single space between do and open brace',
     'EMPTYLINEBRACE'        => 'Empty line before the open brace',
     'EQUALSNOSPACE'         => 'equals sign without following space',
+    'EQUALSPACE'            => 'equals sign with too many spaces following',
     'EQUALSNULL'            => 'if/while comparison with == NULL',
     'ERRNOVAR'              => 'use of bare errno define',
     'EXCLAMATIONSPACE'      => 'Whitespace after exclamation mark in expression',
@@ -1039,6 +1040,12 @@ sub scanfile {
                       $line, length($1)+1, $file, $ol,
                       "no space before equals sign");
         }
+        # check for equals sign with more than one space after it
+        elsif($l =~ /(.*)[a-z0-9] \=  /i) {
+            checkwarn("EQUALSPACE",
+                      $line, length($1)+3, $file, $ol,
+                      "more than one space after equals sign");
+        }
 
         # check for plus signs without spaces next to it
         if($nostr =~ /(.*)[^+]\+[a-z0-9]/i) {
index f831c9bfc252003dea9e86dc374b5de64a72ac2c..84f61202117ca74c98f181563976b7c8dbefd20a 100644 (file)
@@ -205,7 +205,7 @@ static int test_signed_short_formatting(void)
   i++; ss_test[i].num = -0x0050 -1; ss_test[i].expected = "-81";
   i++; ss_test[i].num = -0x0005 -1; ss_test[i].expected = "-6";
 
-  i++; ss_test[i].num =  0x0000 -1; ss_test[i].expected = "-1";
+  i++; ss_test[i].num = 0x0000 -1; ss_test[i].expected = "-1";
 
   num_sshort_tests = i;
 
@@ -431,7 +431,7 @@ static int test_signed_int_formatting(void)
   i++; si_test[i].num = -0x0050 -1; si_test[i].expected = "-81";
   i++; si_test[i].num = -0x0005 -1; si_test[i].expected = "-6";
 
-  i++; si_test[i].num =  0x0000 -1; si_test[i].expected = "-1";
+  i++; si_test[i].num = 0x0000 -1; si_test[i].expected = "-1";
 
   num_sint_tests = i;
 
@@ -498,7 +498,7 @@ static int test_signed_int_formatting(void)
   i++; si_test[i].num = -0x00000050 -1; si_test[i].expected = "-81";
   i++; si_test[i].num = -0x00000005 -1; si_test[i].expected = "-6";
 
-  i++; si_test[i].num =  0x00000000 -1; si_test[i].expected = "-1";
+  i++; si_test[i].num = 0x00000000 -1; si_test[i].expected = "-1";
 
   num_sint_tests = i;
 
@@ -581,7 +581,7 @@ static int test_signed_int_formatting(void)
   i++; si_test[i].num = -0x0000000000000070 -1; si_test[i].expected = "-113";
   i++; si_test[i].num = -0x0000000000000007 -1; si_test[i].expected = "-8";
 
-  i++; si_test[i].num =  0x0000000000000000 -1; si_test[i].expected = "-1";
+  i++; si_test[i].num = 0x0000000000000000 -1; si_test[i].expected = "-1";
 
   num_sint_tests = i;
 
@@ -808,7 +808,7 @@ static int test_signed_long_formatting(void)
   i++; sl_test[i].num = -0x0050L -1L; sl_test[i].expected = "-81";
   i++; sl_test[i].num = -0x0005L -1L; sl_test[i].expected = "-6";
 
-  i++; sl_test[i].num =  0x0000L -1L; sl_test[i].expected = "-1";
+  i++; sl_test[i].num = 0x0000L -1L; sl_test[i].expected = "-1";
 
   num_slong_tests = i;
 
@@ -875,7 +875,7 @@ static int test_signed_long_formatting(void)
   i++; sl_test[i].num = -0x00000050L -1L; sl_test[i].expected = "-81";
   i++; sl_test[i].num = -0x00000005L -1L; sl_test[i].expected = "-6";
 
-  i++; sl_test[i].num =  0x00000000L -1L; sl_test[i].expected = "-1";
+  i++; sl_test[i].num = 0x00000000L -1L; sl_test[i].expected = "-1";
 
   num_slong_tests = i;
 
@@ -958,7 +958,7 @@ static int test_signed_long_formatting(void)
   i++; sl_test[i].num = -0x0000000000000070L -1L; sl_test[i].expected = "-113";
   i++; sl_test[i].num = -0x0000000000000007L -1L; sl_test[i].expected = "-8";
 
-  i++; sl_test[i].num =  0x0000000000000000L -1L; sl_test[i].expected = "-1";
+  i++; sl_test[i].num = 0x0000000000000000L -1L; sl_test[i].expected = "-1";
 
   num_slong_tests = i;
 
@@ -1074,7 +1074,7 @@ static int test_curl_off_t_formatting(void)
   i++; co_test[i].num = -0x0000000000000070 -1; co_test[i].expected = "-113";
   i++; co_test[i].num = -0x0000000000000007 -1; co_test[i].expected = "-8";
 
-  i++; co_test[i].num =  0x0000000000000000 -1; co_test[i].expected = "-1";
+  i++; co_test[i].num = 0x0000000000000000 -1; co_test[i].expected = "-1";
 
   num_cofft_tests = i;
 
index 64f005dfe5f4abd7e111bced3d6e1607e76db38b..31ae5c8a39431c7962773e0d6968173b505f3cd5 100644 (file)
@@ -310,7 +310,7 @@ static struct tftphdr *rw_init(int x)
 {
   newline = 0;                    /* init crlf flag */
   prevchar = -1;
-  bfs[0].counter =  BF_ALLOC;     /* pass out the first buffer */
+  bfs[0].counter = BF_ALLOC;     /* pass out the first buffer */
   current = 0;
   bfs[1].counter = BF_FREE;
   nextone = x;                    /* ahead or behind? */
index 49ff3e69f2ce206801262f6e44b907bee67c1845..1ce367b6a79611c7d19f7f58571b49b684fa70ed 100644 (file)
@@ -148,7 +148,7 @@ static CURLcode test_unit1303(const char *arg)
     timediff_t timeout;
     NOW(run[i].now_s, run[i].now_us);
     TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
-    timeout =  Curl_timeleft(easy, &now, run[i].connecting);
+    timeout = Curl_timeleft(easy, &now, run[i].connecting);
     if(timeout != run[i].result)
       fail(run[i].comment);
   }