Loading lib/Makefile.am +3 −0 Original line number Diff line number Diff line Loading @@ -184,3 +184,6 @@ $(VCPROJ): vc8proj.head vc8proj.foot Makefile.am echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ done; \ cat $(srcdir)/vc8proj.foot $(VCPROJOUT) ) all-local: @for i in $(CSOURCES) $(HHEADERS); do $(top_srcdir)/lib/checksrc.pl $(top_srcdir)/lib/$$i; done lib/asyn-ares.c +3 −4 Original line number Diff line number Diff line Loading @@ -542,10 +542,9 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ /* Otherwise, check if this is an IPv6 address string */ if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) { if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) /* This must be an IPv6 address literal. */ return Curl_ip2addr(AF_INET6, &in6, hostname, port); } switch(conn->ip_version) { default: Loading lib/asyn-thread.c +27 −24 Original line number Diff line number Diff line Loading @@ -225,7 +225,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, #endif tsd->mtx = malloc(sizeof(curl_mutex_t)); if (tsd->mtx == NULL) goto err_exit; if(tsd->mtx == NULL) goto err_exit; Curl_mutex_init(tsd->mtx); Loading @@ -235,7 +236,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, * thread during gethostbyname execution. */ tsd->hostname = strdup(hostname); if (!tsd->hostname) goto err_exit; if(!tsd->hostname) goto err_exit; return 1; Loading Loading @@ -428,11 +430,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, DEBUGASSERT(conn && td); /* wait for the thread to resolve the name */ if (Curl_thread_join(&td->thread_hnd)) { if(Curl_thread_join(&td->thread_hnd)) rc = getaddrinfo_complete(conn); } else { else DEBUGASSERT(0); } conn->async.done = TRUE; Loading @@ -445,7 +446,8 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, failf(data, "Could not resolve proxy: %s; %s", conn->async.hostname, Curl_strerror(conn, conn->async.status)); rc = CURLE_COULDNT_RESOLVE_PROXY; } else { } else { failf(data, "Could not resolve host: %s; %s", conn->async.hostname, Curl_strerror(conn, conn->async.status)); rc = CURLE_COULDNT_RESOLVE_HOST; Loading Loading @@ -493,7 +495,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, return CURLE_COULDNT_RESOLVE_HOST; } *entry = conn->async.dns; } else { } else { /* poll for name lookup done with exponential backoff up to 250ms */ int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle); if(elapsed < 0) Loading lib/axtls.c +2 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,7 @@ int Curl_axtls_cleanup(void) static CURLcode map_error_to_curl(int axtls_err) { switch (axtls_err) { switch (axtls_err) { case SSL_ERROR_NOT_SUPPORTED: case SSL_ERROR_INVALID_VERSION: case -70: /* protocol version alert from server */ Loading lib/checksrc.pl 0 → 100755 +118 −0 Original line number Diff line number Diff line #!/usr/bin/perl my $file=$ARGV[0]; my $max_column = 79; my $indent = 2; sub checkwarn { my ($num, $col, $file, $line, $msg, $error) = @_; my $w=$error?"error":"warning"; $col++; print "$file:$num:$col: $w: $msg\n"; print " $line\n"; if($col < 80) { my $pref = (' ' x $col); print "${pref}^\n"; } } if(!$file) { print "checksrc.pl <single C or H file>\n"; exit; } my $line = 1; open(R, "<$file") || die; my $copyright=0; while(<R>) { chomp; my $l = $_; my $column = 0; # check for a copyright statement if(!$copyright && ($l =~ /copyright .* \d\d\d\d/i)) { $copyright=1; } # detect long lines if(length($l) > $max_column) { checkwarn($line, length($l), $file, $l, "Longer than $max_column columns"); } # detect TAB characters if($l =~ /^(.*)\t/) { checkwarn($line, length($1), $file, $l, "Contains TAB character", 1); } # detect trailing white space if($l =~ /^(\S+)[ \t]+\z/) { checkwarn($line, length($1), $file, $l, "Trailing whitespace"); } # detect return statements with parenthesis # doesn't really work unless we filter off typecasts #if($l =~ /(.*)return \(/) { # checkwarn($line, length($1)+6, $file, $l, "return with paretheses"); #} # check spaces after for/if/while if($l =~ /^(.*)(for|if|while) \(/) { if($1 =~ / *\#/) { # this is a #if, treat it differently } else { checkwarn($line, length($1)+length($2), $file, $l, "$2 with space"); } } # check for "} else" if($l =~ /^(.*)\} else/) { checkwarn($line, length($1), $file, $l, "else after closing brace on same line"); } # check for open brace first on line but not first column # only alert if previous line ended with a close paren and wasn't a cpp # line if((($prevl =~ /\)\z/) && ($prevl !~ /^ *#/)) && ($l =~ /^( +)\{/)) { checkwarn($line, length($1), $file, $l, "badly placed open brace"); } # 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/) { my $first = length($1); # this line has some character besides spaces if(($l !~ /^ *#/) && ($l =~ /^( *)[^ ]/)) { my $second = length($1); my $expect = $first+$indent; if($expect != $second) { my $diff = $second - $first; checkwarn($line, length($1), $file, $l, "not indented $indent steps, uses $diff)"); } } } # check for // letters, but skip them if a double quote or asterisk was # on the same line to avoid strings and comments. Not reliable. #if($l =~ /^([^\"*]*)\/\//) { # checkwarn($line, length($1), $file, $l, "non-C89 compliant comment", # 1); #} $line++; $prevl = $l; } if(!$copyright) { checkwarn(1, 0, $file, "", "Missing copyright statement", 1); } close(R); Loading
lib/Makefile.am +3 −0 Original line number Diff line number Diff line Loading @@ -184,3 +184,6 @@ $(VCPROJ): vc8proj.head vc8proj.foot Makefile.am echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ done; \ cat $(srcdir)/vc8proj.foot $(VCPROJOUT) ) all-local: @for i in $(CSOURCES) $(HHEADERS); do $(top_srcdir)/lib/checksrc.pl $(top_srcdir)/lib/$$i; done
lib/asyn-ares.c +3 −4 Original line number Diff line number Diff line Loading @@ -542,10 +542,9 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ /* Otherwise, check if this is an IPv6 address string */ if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) { if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) /* This must be an IPv6 address literal. */ return Curl_ip2addr(AF_INET6, &in6, hostname, port); } switch(conn->ip_version) { default: Loading
lib/asyn-thread.c +27 −24 Original line number Diff line number Diff line Loading @@ -225,7 +225,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, #endif tsd->mtx = malloc(sizeof(curl_mutex_t)); if (tsd->mtx == NULL) goto err_exit; if(tsd->mtx == NULL) goto err_exit; Curl_mutex_init(tsd->mtx); Loading @@ -235,7 +236,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, * thread during gethostbyname execution. */ tsd->hostname = strdup(hostname); if (!tsd->hostname) goto err_exit; if(!tsd->hostname) goto err_exit; return 1; Loading Loading @@ -428,11 +430,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, DEBUGASSERT(conn && td); /* wait for the thread to resolve the name */ if (Curl_thread_join(&td->thread_hnd)) { if(Curl_thread_join(&td->thread_hnd)) rc = getaddrinfo_complete(conn); } else { else DEBUGASSERT(0); } conn->async.done = TRUE; Loading @@ -445,7 +446,8 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, failf(data, "Could not resolve proxy: %s; %s", conn->async.hostname, Curl_strerror(conn, conn->async.status)); rc = CURLE_COULDNT_RESOLVE_PROXY; } else { } else { failf(data, "Could not resolve host: %s; %s", conn->async.hostname, Curl_strerror(conn, conn->async.status)); rc = CURLE_COULDNT_RESOLVE_HOST; Loading Loading @@ -493,7 +495,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, return CURLE_COULDNT_RESOLVE_HOST; } *entry = conn->async.dns; } else { } else { /* poll for name lookup done with exponential backoff up to 250ms */ int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle); if(elapsed < 0) Loading
lib/axtls.c +2 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,7 @@ int Curl_axtls_cleanup(void) static CURLcode map_error_to_curl(int axtls_err) { switch (axtls_err) { switch (axtls_err) { case SSL_ERROR_NOT_SUPPORTED: case SSL_ERROR_INVALID_VERSION: case -70: /* protocol version alert from server */ Loading
lib/checksrc.pl 0 → 100755 +118 −0 Original line number Diff line number Diff line #!/usr/bin/perl my $file=$ARGV[0]; my $max_column = 79; my $indent = 2; sub checkwarn { my ($num, $col, $file, $line, $msg, $error) = @_; my $w=$error?"error":"warning"; $col++; print "$file:$num:$col: $w: $msg\n"; print " $line\n"; if($col < 80) { my $pref = (' ' x $col); print "${pref}^\n"; } } if(!$file) { print "checksrc.pl <single C or H file>\n"; exit; } my $line = 1; open(R, "<$file") || die; my $copyright=0; while(<R>) { chomp; my $l = $_; my $column = 0; # check for a copyright statement if(!$copyright && ($l =~ /copyright .* \d\d\d\d/i)) { $copyright=1; } # detect long lines if(length($l) > $max_column) { checkwarn($line, length($l), $file, $l, "Longer than $max_column columns"); } # detect TAB characters if($l =~ /^(.*)\t/) { checkwarn($line, length($1), $file, $l, "Contains TAB character", 1); } # detect trailing white space if($l =~ /^(\S+)[ \t]+\z/) { checkwarn($line, length($1), $file, $l, "Trailing whitespace"); } # detect return statements with parenthesis # doesn't really work unless we filter off typecasts #if($l =~ /(.*)return \(/) { # checkwarn($line, length($1)+6, $file, $l, "return with paretheses"); #} # check spaces after for/if/while if($l =~ /^(.*)(for|if|while) \(/) { if($1 =~ / *\#/) { # this is a #if, treat it differently } else { checkwarn($line, length($1)+length($2), $file, $l, "$2 with space"); } } # check for "} else" if($l =~ /^(.*)\} else/) { checkwarn($line, length($1), $file, $l, "else after closing brace on same line"); } # check for open brace first on line but not first column # only alert if previous line ended with a close paren and wasn't a cpp # line if((($prevl =~ /\)\z/) && ($prevl !~ /^ *#/)) && ($l =~ /^( +)\{/)) { checkwarn($line, length($1), $file, $l, "badly placed open brace"); } # 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/) { my $first = length($1); # this line has some character besides spaces if(($l !~ /^ *#/) && ($l =~ /^( *)[^ ]/)) { my $second = length($1); my $expect = $first+$indent; if($expect != $second) { my $diff = $second - $first; checkwarn($line, length($1), $file, $l, "not indented $indent steps, uses $diff)"); } } } # check for // letters, but skip them if a double quote or asterisk was # on the same line to avoid strings and comments. Not reliable. #if($l =~ /^([^\"*]*)\/\//) { # checkwarn($line, length($1), $file, $l, "non-C89 compliant comment", # 1); #} $line++; $prevl = $l; } if(!$copyright) { checkwarn(1, 0, $file, "", "Missing copyright statement", 1); } close(R);