Skip to content

curlx: move Curl_strerror, use in src and tests, ban strerror globally - #18840

Closed
vszakats wants to merge 50 commits into
curl:masterfrom
vszakats:xstrerr
Closed

vszakats wants to merge 50 commits into
curl:masterfrom
vszakats:xstrerr

Conversation

@vszakats

@vszakats vszakats commented Oct 4, 2025 •

Copy link
Copy Markdown
Member

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 45438c8 #18823


  • replace strerror() in tests/server.

@vszakats
vszakats marked this pull request as draft October 4, 2025 02:03
@vszakats vszakats changed the title promote Curl_strerror to curlx_strerror, use it from src, libtests, ban strerror globally promote Curl_strerror to curlx, use it from src, libtests, ban strerror globally Oct 4, 2025
@vszakats vszakats changed the title promote Curl_strerror to curlx, use it from src, libtests, ban strerror globally promote Curl_strerror to curlx, use it in src, libtests, ban strerror globally Oct 4, 2025
@vszakats vszakats changed the title promote Curl_strerror to curlx, use it in src, libtests, ban strerror globally promote Curl_strerror to curlx, use in src, libtests, ban strerror globally Oct 4, 2025
@vszakats
vszakats marked this pull request as ready for review October 4, 2025 15:54
@vszakats
vszakats force-pushed the xstrerr branch 3 times, most recently from a8429d7 to 902aef9 Compare October 5, 2025 17:16
@vszakats vszakats changed the title promote Curl_strerror to curlx, use in src, libtests, ban strerror globally curlx: move Curl_strerror, use in src, libtests, ban strerror globally Oct 5, 2025
@vszakats vszakats changed the title curlx: move Curl_strerror, use in src, libtests, ban strerror globally curlx: move Curl_strerror, use in src and tests, ban strerror globally Oct 5, 2025
…c strerror_r

Also taking note of this:
```
../../src/../lib/curlx/strerr.c: In function ‘curlx_strerror’:
../../src/../lib/curlx/strerr.c:330:31: error: ‘Unknown error ’ directive output truncated writing 14 bytes into a region of size 1 [-Werror=format-truncation=]
  330 |       SNPRINTF(buf, buflen, "Unknown error %d", err);
      |                              ~^~~~~~~~~~~~~
../../src/../lib/curlx/strerr.c:330:29: note: directive argument in the range [0, 2147483647]
  330 |       SNPRINTF(buf, buflen, "Unknown error %d", err);
      |                             ^~~~~~~~~~~~~~~~~~
../../src/../lib/curlx/strerr.c:47:18: note: ‘snprintf’ output between 16 and 25 bytes into a destination of size 1
   47 | #define SNPRINTF snprintf
      |                  ^
../../src/../lib/curlx/strerr.c:330:7: note: in expansion of macro ‘SNPRINTF’
  330 |       SNPRINTF(buf, buflen, "Unknown error %d", err);
      |       ^~~~~~~~
../../src/../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);
      |                                ^
../../src/../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
      |                  ^
../../src/../lib/curlx/strerr.c:328:7: note: in expansion of macro ‘SNPRINTF’
  328 |       SNPRINTF(buf, buflen, "%s", msg);
      |       ^~~~~~~~
cc1: all warnings being treated as errors
```
https://github.com/curl/curl/actions/runs/18259528816/job/51985513869?pr=18840#step:31:1730

try fix 1

try fix 2

fixup brainfart
This reverts commit c44154a.
This reverts commit 52373aa.
This reverts commit 4eaf01c.
It's just a convenient buffer size.
uses curl_m*printf(), mappings not needed.
We might need them in the future. (also in a pending branch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant