]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: force indentation of lines after an else
authorDaniel Gustafsson <daniel@yesql.se>
Wed, 25 Apr 2018 19:53:27 +0000 (21:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Apr 2018 22:51:35 +0000 (00:51 +0200)
This extends the INDENTATION case to also handle 'else' statements
and require proper indentation on the following line. Also fixes the
offending cases found in the codebase.

Closes #2532

lib/checksrc.pl
lib/multi.c
lib/rtsp.c
lib/telnet.c
lib/vtls/schannel.c
src/tool_operate.c
tests/libtest/stub_gssapi.c

index 1a695ba2cdd96cadcd29be90bd1b6293752ce4eb..c90e245eee4660051c1f0a24619e7402ea9fd016 100755 (executable)
@@ -499,9 +499,9 @@ sub scanfile {
         }
 
         # if the previous line starts with if/while/for AND ends with an open
-        # brace, check that this line is indented $indent more steps, if not
-        # a cpp line
-        if($prevl =~ /^( *)(if|while|for)\(.*\{\z/) {
+        # brace, or an else statement, check that this line is indented $indent
+        # more steps, if not a cpp line
+        if($prevl =~ /^( *)((if|while|for)\(.*\{|else)\z/) {
             my $first = length($1);
 
             # this line has some character besides spaces
@@ -511,7 +511,7 @@ sub scanfile {
                 if($expect != $second) {
                     my $diff = $second - $first;
                     checkwarn("INDENTATION", $line, length($1), $file, $ol,
-                              "not indented $indent stepsuses $diff)");
+                              "not indented $indent steps (uses $diff)");
 
                 }
             }
index 5f32dd2a1116c616e15af5e86bc318cbb198e4ec..f85284695239ba425127ab8966ac83aac3c11b56 100644 (file)
@@ -1798,8 +1798,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
       if((data->easy_conn->sockfd != CURL_SOCKET_BAD) ||
          (data->easy_conn->writesockfd != CURL_SOCKET_BAD))
         multistate(data, CURLM_STATE_WAITPERFORM);
-      else
-      {
+      else {
         if(data->state.wildcardmatch &&
            ((data->easy_conn->handler->flags & PROTOPT_WILDCARD) == 0)) {
            data->wildcard.state = CURLWC_DONE;
index 194bc949e9d68de3fd2f3dc420e9c49457b65502..41f30001397dd85ed9f4c1bd5d3c4562c6e22e44 100644 (file)
@@ -764,8 +764,7 @@ CURLcode rtp_client_write(struct connectdata *conn, char *ptr, size_t len)
     writeit = data->set.fwrite_rtp;
     user_ptr = data->set.rtp_out;
   }
-  else
-  {
+  else {
     writeit = data->set.fwrite_func;
     user_ptr = data->set.out;
   }
index 78d3a853d071a4da22d9210a9ed46a7c63fcf9cf..d71c8e067a7b069b730e4a7c58e5197458828108 100644 (file)
@@ -1203,8 +1203,7 @@ CURLcode telrcv(struct connectdata *conn,
           CURL_SB_ACCUM(tn, c);
           tn->telrcv_state = CURL_TS_SB;
         }
-        else
-        {
+        else {
           CURL_SB_ACCUM(tn, CURL_IAC);
           CURL_SB_ACCUM(tn, CURL_SE);
           tn->subpointer -= 2;
index 190ecca23510989b3ae20bd525563c4419c40813..01f6f6691dbe275abd39cfc3ea2e35911f426b12 100644 (file)
@@ -544,8 +544,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
     InitSecBuffer(&inbuf, SECBUFFER_APPLICATION_PROTOCOLS, alpn_buffer, cur);
     InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
   }
-  else
-  {
+  else {
     InitSecBuffer(&inbuf, SECBUFFER_EMPTY, NULL, 0);
     InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
   }
index 932dda6e09255add7e56803db03bcdc02de941a3..626c30888636cf0f893035062b7c62082f410824 100644 (file)
@@ -456,8 +456,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
            the number of resources as urlnum. */
         urlnum = count_next_metalink_resource(mlfile);
       }
-      else
-      if(!config->globoff) {
+      else if(!config->globoff) {
         /* Unless explicitly shut off, we expand '{...}' and '[...]'
            expressions and return total number of URLs in pattern set */
         result = glob_url(&urls, urlnode->url, &urlnum,
@@ -1858,8 +1857,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
              */
             break;
         }
-        else
-        if(urlnum > 1) {
+        else if(urlnum > 1) {
           /* when url globbing, exit loop upon critical error */
           if(is_fatal_error(result))
             break;
index 168becf88d3aea008dcd5b4cad42f9424b2b46ab..883cc1900c1b14f8e590ae412521cf29da2aed9a 100644 (file)
@@ -324,7 +324,7 @@ OM_uint32 gss_display_status(OM_uint32 *min,
     if(status_string->value)
       status_string->length = strlen(status_string->value);
     else
-       return GSS_S_FAILURE;
+      return GSS_S_FAILURE;
   }
 
   return GSS_S_COMPLETE;