mirror of
https://github.com/curl/curl.git
synced 2026-08-26 17:53:33 +03:00
curlx: move Curl_strerror, use in src and tests, ban strerror globally
Also:
- tests/server: replace local `sstrerror()` with `curlx_strerror()`.
- tests/server: show the error code next to the string, where missing.
- curlx: use `curl_msnprintf()` when building for src and tests.
(units was already using it.)
- lib: drop unused includes found along the way.
- curlx_strerror(): avoid compiler warning (and another similar one):
```
In file included from servers.c:14:
../../lib/../../lib/curlx/strerr.c: In function ‘curlx_strerror’:
../../lib/../../lib/curlx/strerr.c:328:32: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
328 | SNPRINTF(buf, buflen, "%s", msg);
| ^
../../lib/../../lib/curlx/strerr.c:47:18: note: ‘snprintf’ output 1 or more bytes (assuming 2) into a destination of size 1
47 | #define SNPRINTF snprintf
| ^
../../lib/../../lib/curlx/strerr.c:328:7: note: in expansion of macro ‘SNPRINTF’
328 | SNPRINTF(buf, buflen, "%s", msg);
| ^~~~~~~~
```
Follow-up to 45438c8d6f #18823
Closes #18840
This commit is contained in:
parent
eaf66f18b7
commit
34ad78da89
53 changed files with 751 additions and 570 deletions
|
|
@ -222,8 +222,9 @@ size_t tool_mime_stdin_read(char *buffer,
|
|||
/* Read from stdin. */
|
||||
nitems = fread(buffer, 1, nitems, stdin);
|
||||
if(ferror(stdin)) {
|
||||
char errbuf[STRERROR_LEN];
|
||||
/* Show error only once. */
|
||||
warnf("stdin: %s", strerror(errno));
|
||||
warnf("stdin: %s", curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
return CURL_READFUNC_ABORT;
|
||||
}
|
||||
}
|
||||
|
|
@ -444,8 +445,9 @@ static int read_field_headers(const char *filename, FILE *fp,
|
|||
switch(c) {
|
||||
case EOF:
|
||||
if(ferror(fp)) {
|
||||
char errbuf[STRERROR_LEN];
|
||||
errorf("Header file %s read error: %s", filename,
|
||||
strerror(errno));
|
||||
curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
return 0; /* Done. */
|
||||
|
|
@ -564,9 +566,11 @@ static int get_param_part(char endchar,
|
|||
sep = *p;
|
||||
*endpos = '\0';
|
||||
fp = curlx_fopen(hdrfile, FOPEN_READTEXT);
|
||||
if(!fp)
|
||||
if(!fp) {
|
||||
char errbuf[STRERROR_LEN];
|
||||
warnf("Cannot read from %s: %s", hdrfile,
|
||||
strerror(errno));
|
||||
curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else {
|
||||
int i = read_field_headers(hdrfile, fp, &headers);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue