strvec_index_valid() -Wtype-limits compiler warning
When -Wtype-limits warnings enabled:
../../../src/utility/string_vector.c: In function ‘strvec_index_valid’:
../../../src/utility/string_vector.c:382:18: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
382 | return svindex >= 0 && svindex < psv->size;
#1 Updated by Marko Lindqvist 5 months ago
- File 0023-Fix-Wtype-limits-compiler-warning-from-strvec_index_.patch 0023-Fix-Wtype-limits-compiler-warning-from-strvec_index_.patch added
- Status changed from In Progress to Resolved
- Target version set to 2.6.2
#3 Updated by Marko Lindqvist 5 months ago
I've been postponing pushing this patch as it's somewhat counter-productive. Though the check is currently pointless (as the warning says), it protects against potential future code changes where the type of the argument changes to a signed one.
Now that I've fixed most of the type-limits warnings, it has turned out that there is just two of these 'counter-productive' cases (this and one other). I think it's worth fixing warnings in these two cases despite the cons, as that would mean clean build with type-limits warnings enabled, and we could actually enable them by default on --enable-debug builds.