mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
clang-tidy: fix readability-suspicious-call-argument
Also: - curlx/strerr: avoid a false positive by dropping an interim variable. - enable this check. Ref: #20627 (initial attempt) Closes #20777
This commit is contained in:
parent
fcde8d7e37
commit
a5c6a4067a
@ -39,6 +39,7 @@ Checks:
|
||||
- readability-redundant-function-ptr-dereference
|
||||
- readability-redundant-parentheses
|
||||
- readability-redundant-preprocessor
|
||||
- readability-suspicious-call-argument
|
||||
- readability-uppercase-literal-suffix
|
||||
|
||||
CheckOptions:
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
static const char *get_winsock_error(int err, char *buf, size_t len)
|
||||
{
|
||||
VERBOSE(const char *p);
|
||||
VERBOSE(size_t alen);
|
||||
|
||||
if(!len)
|
||||
return NULL;
|
||||
@ -221,8 +220,7 @@ static const char *get_winsock_error(int err, char *buf, size_t len)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
alen = strlen(p);
|
||||
curlx_strcopy(buf, len, p, alen);
|
||||
curlx_strcopy(buf, len, p, strlen(p));
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -85,10 +85,10 @@ static size_t my_write_d_cb(char *buf, size_t nitems, size_t buflen,
|
||||
void *userdata)
|
||||
{
|
||||
struct transfer_d *t = userdata;
|
||||
size_t blen = (nitems * buflen);
|
||||
curl_off_t blen = nitems * buflen;
|
||||
size_t nwritten;
|
||||
|
||||
curl_mfprintf(stderr, "[t-%zu] RECV %zu bytes, "
|
||||
curl_mfprintf(stderr, "[t-%zu] RECV %" CURL_FORMAT_CURL_OFF_T " bytes, "
|
||||
"total=%" CURL_FORMAT_CURL_OFF_T ", "
|
||||
"pause_at=%" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
t->idx, blen, t->recv_size, t->pause_at);
|
||||
@ -108,19 +108,19 @@ static size_t my_write_d_cb(char *buf, size_t nitems, size_t buflen,
|
||||
return CURL_WRITEFUNC_PAUSE;
|
||||
}
|
||||
|
||||
nwritten = fwrite(buf, nitems, buflen, t->out);
|
||||
if(nwritten < blen) {
|
||||
nwritten = fwrite(buf, buflen, nitems, t->out);
|
||||
if(nwritten < nitems) {
|
||||
curl_mfprintf(stderr, "[t-%zu] write failure\n", t->idx);
|
||||
return 0;
|
||||
}
|
||||
t->recv_size += (curl_off_t)nwritten;
|
||||
t->recv_size += blen;
|
||||
if(t->fail_at > 0 && t->recv_size >= t->fail_at) {
|
||||
curl_mfprintf(stderr, "[t-%zu] FAIL by write callback at "
|
||||
"%" CURL_FORMAT_CURL_OFF_T " bytes\n", t->idx, t->recv_size);
|
||||
return CURL_WRITEFUNC_ERROR;
|
||||
}
|
||||
|
||||
return nwritten;
|
||||
return (size_t)blen;
|
||||
}
|
||||
|
||||
static int my_progress_d_cb(void *userdata,
|
||||
|
||||
@ -64,10 +64,10 @@ static size_t my_write_u_cb(char *buf, size_t nitems, size_t buflen,
|
||||
void *userdata)
|
||||
{
|
||||
struct transfer_u *t = userdata;
|
||||
size_t blen = (nitems * buflen);
|
||||
curl_off_t blen = nitems * buflen;
|
||||
size_t nwritten;
|
||||
|
||||
curl_mfprintf(stderr, "[t-%zu] RECV %zu bytes, "
|
||||
curl_mfprintf(stderr, "[t-%zu] RECV %" CURL_FORMAT_CURL_OFF_T " bytes, "
|
||||
"total=%" CURL_FORMAT_CURL_OFF_T ", "
|
||||
"pause_at=%" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
t->idx, blen, t->recv_size, t->pause_at);
|
||||
@ -79,13 +79,13 @@ static size_t my_write_u_cb(char *buf, size_t nitems, size_t buflen,
|
||||
return 0;
|
||||
}
|
||||
|
||||
nwritten = fwrite(buf, nitems, buflen, t->out);
|
||||
if(nwritten < blen) {
|
||||
nwritten = fwrite(buf, buflen, nitems, t->out);
|
||||
if(nwritten < nitems) {
|
||||
curl_mfprintf(stderr, "[t-%zu] write failure\n", t->idx);
|
||||
return 0;
|
||||
}
|
||||
t->recv_size += (curl_off_t)nwritten;
|
||||
return nwritten;
|
||||
t->recv_size += blen;
|
||||
return (size_t)blen;
|
||||
}
|
||||
|
||||
static size_t my_read_cb(char *buf, size_t nitems, size_t buflen,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user