llvm-project
28c49b80 - [libc] Add truncation casts to avoid warnings in `file_test.cpp` (#237262)

Commit
15 days ago
[libc] Add truncation casts to avoid warnings in `file_test.cpp` (#237262) `file_test.cpp` has code that mixes `size_t` and `off_t`. In 64-bit platforms this doesn't cause warnings, but in 32-bit the two types have different bitwidths: `size_t` is 32 whereas `off_t` is still 64. This makes clang emit a `-Wshorten-64-to-32` warning. This patch adds explicit castings to silence the warnings. Mixing different bitwidths and even different signedness like this is brittle, as it can cause integer wrapping and unwanted behaviour. However, within the constraints of the test, the code is ok. But one call to `seek()` had an obvious unsigned underflow in its argument. This is fixed. The ultimate goal is to re-enable `-Werror` in 32-bit builds.
Author
Parents
Loading