Commit 1c3e8bbf authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

checksrc: warn for assignments within if() expressions

... they're already frowned upon in our source code style guide, this
now enforces the rule harder.
parent b228d295
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -200,7 +200,8 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
    if(p->verbose > 1)
      X509_print_ex(p->errorbio, ctx->cert, 0, 0);

    if(accessinfo = my_get_ext(ctx->cert, p->accesstype, NID_sinfo_access)) {
    accessinfo = my_get_ext(ctx->cert, p->accesstype, NID_sinfo_access);
    if(accessinfo) {
      if(p->verbose)
        BIO_printf(p->errorbio, "Setting URL from SIA to: %s\n", accessinfo);

@@ -355,7 +356,8 @@ int main(int argc, char **argv)
    }
    else if(strcmp(*args, "-accesstype") == 0) {
      if(args[1]) {
        if((p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0))) == 0)
        p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0));
        if(p.accesstype == 0)
          badarg=1;
      }
      else
@@ -410,16 +412,19 @@ int main(int argc, char **argv)

  p.errorbio = BIO_new_fp(stderr, BIO_NOCLOSE);

  if(!(p.curl = curl_easy_init())) {
  p.curl = curl_easy_init();
  if(!p.curl) {
    BIO_printf(p.errorbio, "Cannot init curl lib\n");
    goto err;
  }

  if(!(p12bio = BIO_new_file(p.p12file, "rb"))) {
  p12bio = BIO_new_file(p.p12file, "rb");
  if(!p12bio) {
    BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file);
    goto err;
  }
  if(!(p.p12 = d2i_PKCS12_bio(p12bio, NULL))) {
  p.p12 = d2i_PKCS12_bio(p12bio, NULL);
  if(!p.p12) {
    BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file);
    goto err;
  }
@@ -447,16 +452,19 @@ int main(int argc, char **argv)
  }
  else if(p.accesstype != 0) { /* see whether we can find an AIA or SIA for a
                                  given access type */
    if(!(serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access))) {
    serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access);
    if(!serverurl) {
      int j=0;
      BIO_printf(p.errorbio, "no service URL in user cert "
                 "cherching in others certificats\n");
      for(j=0; j<sk_X509_num(p.ca); j++) {
        if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
                                    NID_info_access)))
        serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
                               NID_info_access);
        if(serverurl)
          break;
        if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
                                    NID_sinfo_access)))
        serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
                               NID_sinfo_access);
        if(serverurl)
          break;
      }
    }
+6 −5
Original line number Diff line number Diff line
@@ -90,9 +90,8 @@ int main(void)

#ifdef WIN32
  WSADATA wsaData;
  int initwsa;

  if((initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0) {
  int initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData);
  if(initwsa != 0) {
    printf("WSAStartup failed: %d\n", initwsa);
    return 1;
  }
@@ -107,7 +106,8 @@ int main(void)
    curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");

    /* Create the socket "manually" */
    if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD) {
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if(sockfd == CURL_SOCKET_BAD) {
      printf("Error creating listening socket.\n");
      return 3;
    }
@@ -116,7 +116,8 @@ int main(void)
    servaddr.sin_family = AF_INET;
    servaddr.sin_port   = htons(PORTNUM);

    if(INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR)))
    servaddr.sin_addr.s_addr = inet_addr(IPADDR);
    if(INADDR_NONE == servaddr.sin_addr.s_addr)
      return 2;

    if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==
+6 −4
Original line number Diff line number Diff line
@@ -62,12 +62,14 @@ static int _getch(void)

/* error handling macros */
#define my_curl_easy_setopt(A, B, C)                             \
  if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \
  res = curl_easy_setopt((A), (B), (C));                         \
  if(!res)                                                       \
    fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \
            #A, #B, #C, res);

#define my_curl_easy_perform(A)                                     \
  if((res = curl_easy_perform((A))) != CURLE_OK) \
  res = curl_easy_perform(A);                                       \
  if(!res)                                                          \
    fprintf(stderr, "curl_easy_perform(%s) failed: %d\n", #A, res);


+8 −0
Original line number Diff line number Diff line
@@ -356,6 +356,14 @@ sub scanfile {
            }
        }

        if($nostr =~ /^((.*)(if) *\()(.*)\)/) {
            my $pos = length($1);
            if($4 =~ / = /) {
                checkwarn("ASSIGNWITHINCONDITION",
                          $line, $pos+1, $file, $l,
                          "assignment within conditional expression");
            }
        }
        # check spaces after open parentheses
        if($l =~ /^(.*[a-z])\( /i) {
            checkwarn("SPACEAFTERPAREN",
+2 −2
Original line number Diff line number Diff line
@@ -798,8 +798,8 @@ Curl_cookie_add(struct Curl_easy *data,
  /* Check if the domain is a Public Suffix and if yes, ignore the cookie.
     This needs a libpsl compiled with builtin data. */
  if(domain && co->domain && !isip(co->domain)) {
    if(((psl = psl_builtin()) != NULL)
        && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
    psl = psl_builtin();
    if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
      infof(data,
            "cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
            co->name, domain, co->domain);
Loading