checksrc.pl: detect assign followed by more than one space

And fix some code previously doing this.

Closes #19375
This commit is contained in:
Daniel Stenberg 2025-11-05 14:40:18 +01:00
parent c12a1fdd0e
commit 6d7e924e80
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 20 additions and 13 deletions

View 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;

View File

@ -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) {

View 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;

View 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? */

View 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);
}