Skip to content

eliminate many size_t casts - #19495

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:avoid-size_t-casts
Closed

eliminate many size_t casts#19495
icing wants to merge 3 commits into
curl:masterfrom
icing:avoid-size_t-casts

Conversation

@icing

@icing icing commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

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.

Comment thread lib/http2.c Outdated
Comment thread lib/http2.c Outdated
@icing

icing commented Nov 13, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @vszakats !

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.
@icing
icing force-pushed the avoid-size_t-casts branch from 2f80ca3 to 6d57575 Compare November 13, 2025 10:12
@bagder bagder closed this in cb2bcb6 Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants