[Libreoffice] Don't use plain "char" if you want to put negative values into it

Tor Lillqvist tml at iki.fi
Wed Oct 19 22:32:53 PDT 2011


Remember that char is either signed or unsigned, depending on
platform. Sure, char being signed is the much more common thing, but
for instance on ARM Linuxes it is unsigned. So code like:

char nDiff = bDown ? 1 : -1;
...
if( (-1 == nDiff && 0 >= nLevel) ||
     (1 == nDiff && MAXLEVEL - 1 <= nLevel))

is wrong. nDiff will never be -1.

One more reason to always build with --enable-werror.

--tml


More information about the LibreOffice mailing list