From: Gabriel Marin Date: Thu, 3 Oct 2024 16:20:09 +0000 (+0300) Subject: checksrc: add check for spaces around logical AND operators X-Git-Tag: curl-8_11_0~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a58584a881c9aa42b2b2b1441c0734044cf2551c;p=thirdparty%2Fcurl.git checksrc: add check for spaces around logical AND operators Closes #15144 --- diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index c9409d12aa..087ff423bd 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -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; diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 0f727e38b9..7075278de2 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -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;