Unverified Commit 2f13e3d2 authored by Daniel Gustafsson's avatar Daniel Gustafsson Committed by Daniel Stenberg
Browse files

checksrc: force indentation of lines after an else

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
parent 1d71ce84
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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 steps, uses $diff)");
                              "not indented $indent steps (uses $diff)");

                }
            }
+1 −2
Original line number Diff line number Diff line
@@ -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;
+1 −2
Original line number Diff line number Diff line
@@ -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;
  }
+1 −2
Original line number Diff line number Diff line
@@ -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;
+1 −2
Original line number Diff line number Diff line
@@ -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);
  }
Loading