warning: useless cast to type ‘size_t’ {aka ‘unsigned int’} [-Wuseless-cast]
malaterre opened this issue · 3 comments
malaterre commented
Posting as issues for now:
/<<PKGBUILDDIR>>/src/lookup_table.h: In member function ‘void charls::golomb_code_table::add_entry(uint8_t, charls::golomb_code)’:
/<<PKGBUILDDIR>>/src/lookup_table.h:48:30: warning: useless cast to type ‘size_t’ {aka ‘unsigned int’} [-Wuseless-cast]
48 | for (size_t i{}; i < static_cast<size_t>(1U) << (byte_bit_count - length); ++i)
|
and
/<<PKGBUILDDIR>>/fuzztest/main.cpp: In function ‘int main(int, const char* const*)’:
/<<PKGBUILDDIR>>/fuzztest/main.cpp:75:68: warning: useless cast to type ‘unsigned int’ [-Wuseless-cast]
75 | const ssize_t result{write(1, encoded_data.data(), static_cast<unsigned int>(encoded_data.size()))};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/fuzztest/main.cpp:99:62: warning: useless cast to type ‘unsigned int’ [-Wuseless-cast]
99 | const size_t input_length = _read(fd, source.data(), static_cast<unsigned int>(source.size()));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 68%] Linking CXX executable fuzztest
malaterre commented
vbaderks commented
Using conditional_static_cast is indeed a very clean way to solve it.