]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: verify do-while and spaces between the braces
authorDaniel Stenberg <daniel@haxx.se>
Mon, 24 Aug 2020 07:31:39 +0000 (09:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 24 Aug 2020 14:38:17 +0000 (16:38 +0200)
Updated mprintf.c to comply

Closes #5845

lib/checksrc.pl
lib/mprintf.c

index 498da94bbc9d730dfe3e3e5aedc704e8d29b756a..e7eb454f1d59c25a8d5cdec673e38157d6ec2fe0 100755 (executable)
@@ -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;
index 80735be51bd2a8c2f45c709f2525faf9a0347b7b..6b62fdfbc57878b10d2cbad6b45036ea6a00b0c2 100644 (file)
@@ -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 */