aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-12-14 01:29:44 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-12-14 01:29:44 +0100
commit1c3e8bbfedcd3822aeb1bab22fb56c5ecff4295b (patch)
treec1606588aeae4535f0faa7942fcbe50e6e340f8b /src
parentb228d2952b6762b5c9b851fba0cf391e80c6761a (diff)
checksrc: warn for assignments within if() expressions
... they're already frowned upon in our source code style guide, this now enforces the rule harder.
Diffstat (limited to 'src')
-rw-r--r--src/tool_getparam.c14
-rw-r--r--src/tool_paramhlp.c15
-rw-r--r--src/tool_writeout.c7
3 files changed, 27 insertions, 9 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 247f8d38c..9b5c9a54c 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -757,7 +757,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
case '@': /* the URL! */
{
struct getout *url;
- if(config->url_get || ((config->url_get = config->url_list) != NULL)) {
+
+ if(!config->url_get)
+ config->url_get = config->url_list;
+
+ if(config->url_get) {
/* there's a node here, if it already is filled-in continue to find
an "empty" node */
while(config->url_get && (config->url_get->flags & GETOUT_URL))
@@ -1687,7 +1691,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
/* output file */
{
struct getout *url;
- if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
+ if(!config->url_out)
+ config->url_out = config->url_list;
+ if(config->url_out) {
/* there's a node here, if it already is filled-in continue to find
an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
@@ -1824,7 +1830,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
/* we are uploading */
{
struct getout *url;
- if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
+ if(!config->url_out)
+ config->url_out = config->url_list;
+ if(config->url_out) {
/* there's a node here, if it already is filled-in continue to find
an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index 09910a784..257e5c697 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -66,12 +66,15 @@ ParameterError file2string(char **bufp, FILE *file)
if(file) {
while(fgets(buffer, sizeof(buffer), file)) {
- if((ptr = strchr(buffer, '\r')) != NULL)
+ ptr = strchr(buffer, '\r');
+ if(ptr)
*ptr = '\0';
- if((ptr = strchr(buffer, '\n')) != NULL)
+ ptr = strchr(buffer, '\n');
+ if(ptr)
*ptr = '\0';
buflen = strlen(buffer);
- if((ptr = realloc(string, stringlen+buflen+1)) == NULL) {
+ ptr = realloc(string, stringlen+buflen+1);
+ if(!ptr) {
Curl_safefree(string);
return PARAM_NO_MEM;
}
@@ -102,7 +105,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
}
alloc *= 2;
/* allocate an extra char, reserved space, for null termination */
- if((newbuf = realloc(buffer, alloc+1)) == NULL) {
+ newbuf = realloc(buffer, alloc+1);
+ if(!newbuf) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
}
@@ -115,7 +119,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
buffer[nused] = '\0';
/* free trailing slack space, if possible */
if(alloc != nused) {
- if((newbuf = realloc(buffer, nused+1)) == NULL) {
+ newbuf = realloc(buffer, nused+1);
+ if(!newbuf) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
}
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index e1b7819ed..2fb77742a 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -124,9 +124,14 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
char *end;
char keepit;
int i;
- if(('{' == ptr[1]) && ((end = strchr(ptr, '}')) != NULL)) {
+ if('{' == ptr[1]) {
bool match = FALSE;
+ end = strchr(ptr, '}');
ptr += 2; /* pass the % and the { */
+ if(!end) {
+ fputs("%{", stream);
+ continue;
+ }
keepit = *end;
*end = 0; /* zero terminate */
for(i = 0; replacements[i].name; i++) {