3 ms·
> For much of the code, lengths were converted from ints to size_ts and functions that returned one, zero or minus one were converted to just returning one or z
by astrange 11y ago
> For much of the code, lengths were converted from ints to size_ts and functions that returned one, zero or minus one were converted to just returning one or zero.
Doesn't google's C code style require using signed ints for lengths?
https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Integer_Types https://google-styleguide.googlecode.com/svn/trunk/cppguide....
As it should - it's inappropriate to use unsigned types for length because the overflow and underflow behaviors are defined, since they're not defined to what you want. When you have ubsan around, adding defined behavior you don't need just adds places to hide bugs.
- agl 11y agoOverflow can happen and we test for it wherever possible (at least that's the hope). By using unsigned lengths, the overflow tests are simple: x + y < x. We also don't have to worry about negative values which, in my experience, are at risk of being forgotten more often than excessively large ones.
- helmut_hed 11y agoIn this case, and many others, Google's code style guidelines are controversial...