From: Daniel Stenberg Date: Wed, 5 Nov 2025 13:40:18 +0000 (+0100) Subject: checksrc.pl: detect assign followed by more than one space X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d7e924e80096a7e2cebad16235674fd3d3012af;p=thirdparty%2Fcurl.git checksrc.pl: detect assign followed by more than one space And fix some code previously doing this. Closes #19375 --- diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index f9bd827374..b0638c6642 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -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; diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 7059d68575..5dcad3e315 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -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) { diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index f831c9bfc2..84f6120211 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -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; diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 64f005dfe5..31ae5c8a39 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -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? */ diff --git a/tests/unit/unit1303.c b/tests/unit/unit1303.c index 49ff3e69f2..1ce367b6a7 100644 --- a/tests/unit/unit1303.c +++ b/tests/unit/unit1303.c @@ -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); }