Unverified Commit cb529b71 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

checksrc: make sure sizeof() is used *with* parentheses

... and unify the source code to adhere.

Closes #2563
parent f3d836b7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -111,7 +111,7 @@ err:

    fprintf(stderr, "error adding certificate\n");
    if(error) {
      ERR_error_string_n(error, errbuf, sizeof errbuf);
      ERR_error_string_n(error, errbuf, sizeof(errbuf));
      fprintf(stderr, "%s\n", errbuf);
    }
  }
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -50,7 +50,7 @@ static curl_context_t* create_curl_context(curl_socket_t sockfd)
{
  curl_context_t *context;

  context = (curl_context_t *) malloc(sizeof *context);
  context = (curl_context_t *) malloc(sizeof(*context));

  context->sockfd = sockfd;

+12 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ my %warnings = (
    'NOSPACEEQUALS'    => 'equals sign without preceding space',
    'SEMINOSPACE'      => 'semicolon without following space',
    'MULTISPACE'       => 'multiple spaces used when not suitable',
    'SIZEOFNOPAREN'    => 'use of sizeof without parentheses',
    );

sub readwhitelist {
@@ -417,6 +418,17 @@ sub scanfile {
            }
        }

        # check for "sizeof" without parenthesis
        if(($l =~ /^(.*)sizeof *([ (])/) && ($2 ne "(")) {
            if($1 =~ / *\#/) {
                # this is a #if, treat it differently
            }
            else {
                checkwarn("SIZEOFNOPAREN", $line, length($1)+6, $file, $l,
                          "sizeof without parenthesis");
            }
        }

        # check for comma without space
        if($l =~ /^(.*),[^ \n]/) {
            my $pref=$1;
+1 −1
Original line number Diff line number Diff line
@@ -725,7 +725,7 @@ int curl_formget(struct curl_httppost *form, void *arg,

  while(!result) {
    char buffer[8192];
    size_t nread = Curl_mime_read(buffer, 1, sizeof buffer, &toppart);
    size_t nread = Curl_mime_read(buffer, 1, sizeof(buffer), &toppart);

    if(!nread)
      break;
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -58,7 +58,7 @@ Curl_HMAC_init(const HMAC_params * hashparams,
  unsigned char b;

  /* Create HMAC context. */
  i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize +
  i = sizeof(*ctxt) + 2 * hashparams->hmac_ctxtsize +
    hashparams->hmac_resultlen;
  ctxt = malloc(i);

Loading