summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-08-24 09:31:39 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-08-24 16:38:17 +0200
commit4ebac06106825a5d28be4c38e62732c911168605 (patch)
treeed47f706f59cd2f6ce69102349adf640caf4dae0
parent4be1f8dc01013e4dee2b99026cd3b806ea7253c4 (diff)
downloadcurl-4ebac06106825a5d28be4c38e62732c911168605.tar.gz
checksrc: verify do-while and spaces between the braces
Updated mprintf.c to comply Closes #5845
-rwxr-xr-xlib/checksrc.pl10
-rw-r--r--lib/mprintf.c10
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 498da94bb..e7eb454f1 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -82,6 +82,8 @@ my %warnings = (
'SNPRINTF' => 'use of snprintf',
'ONELINECONDITION' => 'conditional block on the same line as the if()',
'TYPEDEFSTRUCT' => 'typedefed struct',
+ 'DOBRACE' => 'A single space between do and open brace',
+ 'BRACEWHILE' => 'A single space between open brace and while',
);
sub readskiplist {
@@ -468,6 +470,14 @@ sub scanfile {
}
}
+ # check spaces in 'do {'
+ if($nostr =~ /^( *)do( *)\{/ && length($2) != 1) {
+ checkwarn("DOBRACE", $line, length($1) + 2, $file, $l, "one space after do before brace");
+ }
+ # check spaces in 'do {'
+ elsif($nostr =~ /^( *)\}( *)while/ && length($2) != 1) {
+ checkwarn("BRACEWHILE", $line, length($1) + 2, $file, $l, "one space between brace and while");
+ }
if($nostr =~ /^((.*\s)(if) *\()(.*)\)(.*)/) {
my $pos = length($1);
my $postparen = $5;
diff --git a/lib/mprintf.c b/lib/mprintf.c
index 80735be51..6b62fdfbc 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -99,12 +99,12 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Upper-case digits. */
static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#define OUTCHAR(x) \
- do{ \
+#define OUTCHAR(x) \
+ do { \
if(stream((unsigned char)(x), (FILE *)data) != -1) \
- done++; \
- else \
- return done; /* return immediately on failure */ \
+ done++; \
+ else \
+ return done; /* return immediately on failure */ \
} while(0)
/* Data type to read from the arglist */