From 1c3e8bbfedcd3822aeb1bab22fb56c5ecff4295b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Dec 2016 01:29:44 +0100 Subject: checksrc: warn for assignments within if() expressions ... they're already frowned upon in our source code style guide, this now enforces the rule harder. --- tests/server/getpart.c | 9 ++++++--- tests/server/rtspd.c | 18 ++++++++++++------ tests/server/sockfilt.c | 18 ++++++++++++------ tests/server/sws.c | 18 ++++++++++++------ tests/server/tftpd.c | 15 ++++++++++----- 5 files changed, 52 insertions(+), 26 deletions(-) (limited to 'tests/server') diff --git a/tests/server/getpart.c b/tests/server/getpart.c index 1952fbbe5..25758bd4e 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -309,7 +309,8 @@ int getpart(char **outbuf, size_t *outlen, ptr++; end = ptr; EAT_WORD(end); - if((len.sig = end - ptr) > MAX_TAG_LEN) { + len.sig = end - ptr; + if(len.sig > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } @@ -370,7 +371,8 @@ int getpart(char **outbuf, size_t *outlen, /* get potential tag */ end = ptr; EAT_WORD(end); - if((len.sig = end - ptr) > MAX_TAG_LEN) { + len.sig = end - ptr; + if(len.sig > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } @@ -389,7 +391,8 @@ int getpart(char **outbuf, size_t *outlen, end = ptr; while(*end && ('>' != *end)) end++; - if((len.sig = end - ptr) > MAX_TAG_LEN) { + len.sig = end - ptr; + if(len.sig > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index e759e8800..ea231da3d 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -260,36 +260,42 @@ static void install_signal_handlers(void) { #ifdef SIGHUP /* ignore SIGHUP signal */ - if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) + old_sighup_handler = signal(SIGHUP, SIG_IGN); + if(old_sighup_handler == SIG_ERR) logmsg("cannot install SIGHUP handler: %s", strerror(errno)); #endif #ifdef SIGPIPE /* ignore SIGPIPE signal */ - if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) + old_sigpipe_handler = signal(SIGPIPE, SIG_IGN); + if(old_sigpipe_handler == SIG_ERR) logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); #endif #ifdef SIGALRM /* ignore SIGALRM signal */ - if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) + old_sigalrm_handler = signal(SIGALRM, SIG_IGN); + if(old_sigalrm_handler == SIG_ERR) logmsg("cannot install SIGALRM handler: %s", strerror(errno)); #endif #ifdef SIGINT /* handle SIGINT signal with our exit_signal_handler */ - if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) + old_sigint_handler = signal(SIGINT, exit_signal_handler); + if(old_sigint_handler == SIG_ERR) logmsg("cannot install SIGINT handler: %s", strerror(errno)); else siginterrupt(SIGINT, 1); #endif #ifdef SIGTERM /* handle SIGTERM signal with our exit_signal_handler */ - if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) + old_sigterm_handler = signal(SIGTERM, exit_signal_handler); + if(old_sigterm_handler == SIG_ERR) logmsg("cannot install SIGTERM handler: %s", strerror(errno)); else siginterrupt(SIGTERM, 1); #endif #if defined(SIGBREAK) && defined(WIN32) /* handle SIGBREAK signal with our exit_signal_handler */ - if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) + old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler); + if(old_sigbreak_handler == SIG_ERR) logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); else siginterrupt(SIGBREAK, 1); diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index e064b6c7d..78588d3ab 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -206,36 +206,42 @@ static void install_signal_handlers(void) { #ifdef SIGHUP /* ignore SIGHUP signal */ - if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) + old_sighup_handler = signal(SIGHUP, SIG_IGN); + if(old_sighup_handler == SIG_ERR) logmsg("cannot install SIGHUP handler: %s", strerror(errno)); #endif #ifdef SIGPIPE /* ignore SIGPIPE signal */ - if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) + old_sigpipe_handler = signal(SIGPIPE, SIG_IGN); + if(old_sigpipe_handler == SIG_ERR) logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); #endif #ifdef SIGALRM /* ignore SIGALRM signal */ - if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) + old_sigalrm_handler = signal(SIGALRM, SIG_IGN); + if(old_sigalrm_handler == SIG_ERR) logmsg("cannot install SIGALRM handler: %s", strerror(errno)); #endif #ifdef SIGINT /* handle SIGINT signal with our exit_signal_handler */ - if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) + old_sigint_handler = signal(SIGINT, exit_signal_handler); + if(old_sigint_handler == SIG_ERR) logmsg("cannot install SIGINT handler: %s", strerror(errno)); else siginterrupt(SIGINT, 1); #endif #ifdef SIGTERM /* handle SIGTERM signal with our exit_signal_handler */ - if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) + old_sigterm_handler = signal(SIGTERM, exit_signal_handler); + if(old_sigterm_handler == SIG_ERR) logmsg("cannot install SIGTERM handler: %s", strerror(errno)); else siginterrupt(SIGTERM, 1); #endif #if defined(SIGBREAK) && defined(WIN32) /* handle SIGBREAK signal with our exit_signal_handler */ - if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) + old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler); + if(old_sigbreak_handler == SIG_ERR) logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); else siginterrupt(SIGBREAK, 1); diff --git a/tests/server/sws.c b/tests/server/sws.c index af0904e29..c4125a0a8 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -265,36 +265,42 @@ static void install_signal_handlers(void) { #ifdef SIGHUP /* ignore SIGHUP signal */ - if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) + old_sighup_handler = signal(SIGHUP, SIG_IGN); + if(old_sighup_handler == SIG_ERR) logmsg("cannot install SIGHUP handler: %s", strerror(errno)); #endif #ifdef SIGPIPE /* ignore SIGPIPE signal */ - if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) + old_sigpipe_handler = signal(SIGPIPE, SIG_IGN); + if(old_sigpipe_handler == SIG_ERR) logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); #endif #ifdef SIGALRM /* ignore SIGALRM signal */ - if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) + old_sigalrm_handler = signal(SIGALRM, SIG_IGN); + if(old_sigalrm_handler == SIG_ERR) logmsg("cannot install SIGALRM handler: %s", strerror(errno)); #endif #ifdef SIGINT /* handle SIGINT signal with our exit_signal_handler */ - if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) + old_sigint_handler = signal(SIGINT, exit_signal_handler); + if(old_sigint_handler == SIG_ERR) logmsg("cannot install SIGINT handler: %s", strerror(errno)); else siginterrupt(SIGINT, 1); #endif #ifdef SIGTERM /* handle SIGTERM signal with our exit_signal_handler */ - if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) + old_sigterm_handler = signal(SIGTERM, exit_signal_handler); + if(old_sigterm_handler == SIG_ERR) logmsg("cannot install SIGTERM handler: %s", strerror(errno)); else siginterrupt(SIGTERM, 1); #endif #if defined(SIGBREAK) && defined(WIN32) /* handle SIGBREAK signal with our exit_signal_handler */ - if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) + old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler); + if(old_sigbreak_handler == SIG_ERR) logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); else siginterrupt(SIGBREAK, 1); diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 8a4ed0b19..c8667437e 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -367,31 +367,36 @@ static void install_signal_handlers(void) { #ifdef SIGHUP /* ignore SIGHUP signal */ - if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) + old_sighup_handler = signal(SIGHUP, SIG_IGN); + if(old_sighup_handler == SIG_ERR) logmsg("cannot install SIGHUP handler: %s", strerror(errno)); #endif #ifdef SIGPIPE /* ignore SIGPIPE signal */ - if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) + old_sigpipe_handler = signal(SIGPIPE, SIG_IGN); + if(old_sigpipe_handler == SIG_ERR) logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); #endif #ifdef SIGINT /* handle SIGINT signal with our exit_signal_handler */ - if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) + old_sigint_handler = signal(SIGINT, exit_signal_handler); + if(old_sigint_handler == SIG_ERR) logmsg("cannot install SIGINT handler: %s", strerror(errno)); else siginterrupt(SIGINT, 1); #endif #ifdef SIGTERM /* handle SIGTERM signal with our exit_signal_handler */ - if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) + old_sigterm_handler = signal(SIGTERM, exit_signal_handler); + if(old_sigterm_handler == SIG_ERR) logmsg("cannot install SIGTERM handler: %s", strerror(errno)); else siginterrupt(SIGTERM, 1); #endif #if defined(SIGBREAK) && defined(WIN32) /* handle SIGBREAK signal with our exit_signal_handler */ - if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) + old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler); + if(old_sigbreak_handler == SIG_ERR) logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); else siginterrupt(SIGBREAK, 1); -- cgit v1.2.3