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 09:31:39 +0200
commit377da7ab8e57a18a996e76c637b4e58b283abd19 (patch)
tree7001e9110eff0bbb952c6b5d9a862369f35eaf1f
parentbc3b5bcf87f9fe16514f8cfd84cded24a367ac95 (diff)
downloadcurl-bagder/checksrc-dowhile-brace.tar.gz
checksrc: verify do-while and spaces between the bracesbagder/checksrc-dowhile-brace
Updated mprintf.c to comply
-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 */