src/lib: remove redundant ternary operators

Closes #15435
This commit is contained in:
Daniel Stenberg 2024-10-28 17:26:19 +01:00
parent 080973dcdb
commit cd2b45201a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
32 changed files with 68 additions and 75 deletions

View file

@ -173,7 +173,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
log_line_start(output, timebuf, idsbuf, type);
(void)fwrite(data + st, i - st + 1, 1, output);
}
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
newl = (size && (data[size - 1] != '\n'));
traced_data = FALSE;
break;
case CURLINFO_TEXT:
@ -181,7 +181,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
if(!newl)
log_line_start(output, timebuf, idsbuf, type);
(void)fwrite(data, size, 1, output);
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
newl = (size && (data[size - 1] != '\n'));
traced_data = FALSE;
break;
case CURLINFO_DATA_OUT:

View file

@ -1218,7 +1218,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->disallow_username_in_url = toggle;
break;
case C_EPSV: /* --epsv */
config->disable_epsv = (!toggle) ? TRUE : FALSE;
config->disable_epsv = !toggle;
break;
case C_DNS_SERVERS: /* --dns-servers */
if(!curlinfo->ares_num) /* c-ares is needed for this */
@ -1248,7 +1248,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
}
break;
case C_ALPN: /* --alpn */
config->noalpn = (!toggle) ? TRUE : FALSE;
config->noalpn = !toggle;
break;
case C_LIMIT_RATE: /* --limit-rate */
err = GetSizeParameter(global, nextarg, "rate", &value);
@ -1371,7 +1371,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->disable_eprt = toggle;
break;
case C_EPRT: /* --eprt */
config->disable_eprt = (!toggle) ? TRUE : FALSE;
config->disable_eprt = !toggle;
break;
case C_XATTR: /* --xattr */
config->xattr = toggle;
@ -1552,7 +1552,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->ftp_ssl_reqd = toggle;
break;
case C_SESSIONID: /* --sessionid */
config->disable_sessionid = (!toggle) ? TRUE : FALSE;
config->disable_sessionid = !toggle;
break;
case C_FTP_SSL_CONTROL: /* --ftp-ssl-control */
if(toggle && !feature_ssl)
@ -1582,7 +1582,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->raw = toggle;
break;
case C_KEEPALIVE: /* --keepalive */
config->nokeepalive = (!toggle) ? TRUE : FALSE;
config->nokeepalive = !toggle;
break;
case C_KEEPALIVE_TIME: /* --keepalive-time */
err = str2unum(&config->alivetime, nextarg);
@ -2167,7 +2167,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
nextarg,
&config->mimeroot,
&config->mimecurrent,
(cmd == C_FORM_STRING) ? TRUE : FALSE)) /* literal string */
(cmd == C_FORM_STRING))) /* literal string */
err = PARAM_BAD_USE;
else if(SetHTTPrequest(config, TOOL_HTTPREQ_MIMEPOST, &config->httpreq))
err = PARAM_BAD_USE;

View file

@ -2456,7 +2456,7 @@ static CURLcode add_parallel_transfers(struct GlobalConfig *global,
all_added++;
*addedp = TRUE;
}
*morep = (per || sleeping) ? TRUE : FALSE;
*morep = (per || sleeping);
return CURLE_OK;
}

View file

@ -66,8 +66,7 @@ bool output_expected(const char *url, const char *uploadfile)
bool stdin_upload(const char *uploadfile)
{
return (!strcmp(uploadfile, "-") ||
!strcmp(uploadfile, ".")) ? TRUE : FALSE;
return (!strcmp(uploadfile, "-") || !strcmp(uploadfile, "."));
}
/* Convert a CURLUcode into a CURLcode */

View file

@ -126,7 +126,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
option = line;
/* the option starts with a dash? */
dashed_option = (option[0] == '-') ? TRUE : FALSE;
dashed_option = (option[0] == '-');
while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option))
line++;
@ -311,7 +311,7 @@ static bool my_get_line(FILE *fp, struct curlx_dynbuf *db,
occurs while no characters have been read. */
if(!fgets(buf, sizeof(buf), fp))
/* only if there is data in the line, return TRUE */
return curlx_dyn_len(db) ? TRUE : FALSE;
return curlx_dyn_len(db);
if(curlx_dyn_add(db, buf)) {
*error = TRUE; /* error */
return FALSE; /* stop reading */