From 2dc1a5ce93514d4354fa01229756fc48c00513d9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Mar 2015 14:06:48 +0100 Subject: [PATCH] checksrc: detect and remove space before trailing semicolons --- lib/checksrc.pl | 5 +++++ lib/http.c | 2 +- lib/http_chunks.c | 2 +- lib/memdebug.c | 32 ++++++++++++++++---------------- lib/tftp.c | 6 +++--- lib/vtls/openssl.c | 2 +- lib/vtls/polarssl.c | 2 +- src/tool_urlglob.h | 4 ++-- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/lib/checksrc.pl b/lib/checksrc.pl index 190f00c9386378..7a7e3a94c0f187 100755 --- a/lib/checksrc.pl +++ b/lib/checksrc.pl @@ -216,6 +216,11 @@ sub scanfile { checkwarn($line, length($1)+1, $file, $l, "missing space after close paren"); } + # check for space before the semicolon last in a line + if($l =~ /^(.*[^ ].*) ;$/) { + checkwarn($line, length($1), $file, $l, "space before last semicolon"); + } + # scan for use of banned functions if($l =~ /^(.*\W)(sprintf|vsprintf|strcat|strncat|gets)\s*\(/) { checkwarn($line, length($1), $file, $l, diff --git a/lib/http.c b/lib/http.c index 0c08204f28e099..0af471045ed035 100644 --- a/lib/http.c +++ b/lib/http.c @@ -731,7 +731,7 @@ Curl_http_output_auth(struct connectdata *conn, if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) || conn->bits.user_passwd) - /* continue please */ ; + /* continue please */; else { authhost->done = TRUE; authproxy->done = TRUE; diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 3f5003e840ed51..0b1a5ed379d109 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -155,7 +155,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, if(result) { /* Curl_convert_from_network calls failf if unsuccessful */ /* Treat it as a bad hex character */ - return CHUNKE_ILLEGAL_HEX ; + return CHUNKE_ILLEGAL_HEX; } ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16); diff --git a/lib/memdebug.c b/lib/memdebug.c index 931a9f757db4cf..3b38a749259ed6 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -342,10 +342,10 @@ curl_socket_t curl_socket(int domain, int type, int protocol, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socket() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socket() = %ld\n" : - "FD %s:%d socket() = %zd\n" ; + "FD %s:%d socket() = %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d socket() = %ld\n" : + "FD %s:%d socket() = %zd\n"; curl_socket_t sockfd = socket(domain, type, protocol); @@ -361,10 +361,10 @@ int curl_socketpair(int domain, int type, int protocol, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socketpair() = %d %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socketpair() = %ld %ld\n" : - "FD %s:%d socketpair() = %zd %zd\n" ; + "FD %s:%d socketpair() = %d %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d socketpair() = %ld %ld\n" : + "FD %s:%d socketpair() = %zd %zd\n"; int res = socketpair(domain, type, protocol, socket_vector); @@ -379,10 +379,10 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d accept() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d accept() = %ld\n" : - "FD %s:%d accept() = %zd\n" ; + "FD %s:%d accept() = %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d accept() = %ld\n" : + "FD %s:%d accept() = %zd\n"; struct sockaddr *addr = (struct sockaddr *)saddr; curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen; @@ -399,10 +399,10 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen, void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d sclose(%d)\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d sclose(%ld)\n" : - "FD %s:%d sclose(%zd)\n" ; + "FD %s:%d sclose(%d)\n": + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d sclose(%ld)\n": + "FD %s:%d sclose(%zd)\n"; if(source) curl_memlog(fmt, source, line, sockfd); diff --git a/lib/tftp.c b/lib/tftp.c index f837b35d13eb59..56dabc6df410b6 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -145,8 +145,8 @@ typedef struct tftp_state_data { /* Forward declarations */ -static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) ; -static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) ; +static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event); +static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event); static CURLcode tftp_connect(struct connectdata *conn, bool *done); static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection); @@ -218,7 +218,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state) state->max_time = state->start_time+maxtime; /* Set per-block timeout to total */ - timeout = maxtime ; + timeout = maxtime; /* Average restart after 5 seconds */ state->retry_max = (int)timeout/5; diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index f5610bb1e853f9..f0c97f044694c4 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -1236,7 +1236,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert) unsigned char *nulstr = (unsigned char *)""; unsigned char *peer_CN = nulstr; - X509_NAME *name = X509_get_subject_name(server_cert) ; + X509_NAME *name = X509_get_subject_name(server_cert); if(name) while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i))>=0) i=j; diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c index cafcec2b329022..0a7311c2c78e8e 100644 --- a/lib/vtls/polarssl.c +++ b/lib/vtls/polarssl.c @@ -496,7 +496,7 @@ polarssl_connect_step3(struct connectdata *conn, struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct SessionHandle *data = conn->data; void *old_ssl_sessionid = NULL; - ssl_session *our_ssl_sessionid = &conn->ssl[sockindex].ssn ; + ssl_session *our_ssl_sessionid = &conn->ssl[sockindex].ssn; bool incache; DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); diff --git a/src/tool_urlglob.h b/src/tool_urlglob.h index 7a9ec5943e8cef..62c1abdd6d582b 100644 --- a/src/tool_urlglob.h +++ b/src/tool_urlglob.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -51,7 +51,7 @@ typedef struct { int padlength; unsigned long ptr_n; unsigned long step; - } NumRange ; + } NumRange; } content; } URLPattern;