bytecodealliance / rustix

Safe Rust bindings to POSIX-ish APIs
Other
1.46k stars 152 forks source link

Fix `fcntl_setpipe_size` return value #1164

Closed jjyyxx closed 2 weeks ago

jjyyxx commented 2 weeks ago

fcntl man page says that:

F_SETPIPE_SZ ... The actual capacity (in bytes) that is set is returned as the function result.

But the current fcntl_setpipe_size function assumes that the return value is 0 (success) or negative (failure). This makes the function panic due to debug_assert! in debug mode, and it returns Err on success in release mode.

This commit fixes the return value type and its checking, and adds a test for it.

Closes #1163

sunfishcode commented 2 weeks ago

Thanks!