Skip to content

Commit

Permalink
checksrc: detect and remove space before trailing semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Mar 17, 2015
1 parent 0037eb5 commit 2dc1a5c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 25 deletions.
5 changes: 5 additions & 0 deletions lib/checksrc.pl
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/http.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/http_chunks.c
Expand Up @@ -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);
Expand Down
32 changes: 16 additions & 16 deletions lib/memdebug.c
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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;
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/tftp.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/vtls/openssl.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/vtls/polarssl.c
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/tool_urlglob.h
Expand Up @@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2015, 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
Expand Down Expand Up @@ -51,7 +51,7 @@ typedef struct {
int padlength;
unsigned long ptr_n;
unsigned long step;
} NumRange ;
} NumRange;
} content;
} URLPattern;

Expand Down

0 comments on commit 2dc1a5c

Please sign in to comment.