]> git.ipfire.org Git - thirdparty/curl.git/commit
lib: eliminate size_t casts
authorStefan Eissing <stefan@eissing.org>
Wed, 12 Nov 2025 14:58:49 +0000 (15:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 13 Nov 2025 12:32:19 +0000 (13:32 +0100)
commitcb2bcb681fc9044d2a7adaaa6210b61e2f7cff59
tree1ac90b27d441789c05fa9f8cab5c794cec5b644e
parent78a610cb832e9cd6441edc1b9cf5acf57bef28f5
lib: eliminate size_t casts

Add new functions in `curlx/warnless.h` for controlled type
conversions:

* curlx_uitouz, convert unsigned into to size_t (should always work)
* curlx_uztoso, convert size_t to curl_off_t, capping at CURL_OFF_T_MAX
* curlx_sztouz, convert ssize_t to size_t, return TRUE when ok
* curlx_sotouz_range, convert curl_off_t to size_t interval, capping
  values to interval bounds

Remove some unnecesary casts, convert some internal recv functions
to the "return result, have size_t* arg" pattern.

Closes #19495
13 files changed:
lib/cf-h1-proxy.c
lib/cf-h2-proxy.c
lib/curlx/warnless.c
lib/curlx/warnless.h
lib/dict.c
lib/http.c
lib/http2.c
lib/multi.c
lib/sendf.c
lib/setopt.c
lib/transfer.c
lib/vquic/curl_ngtcp2.c
lib/ws.c