util: suppress some uninitialized variable warnings#6659
util: suppress some uninitialized variable warnings#6659ethomson merged 5 commits intolibgit2:mainfrom
Conversation
|
Also replaced index() with strchr(). index() isn't POSIX and won't compile on some systems. |
In C99 functions need to be declared before they are defined. We could just add the declarations before them, but including the header allows the compiler to warn if they differ.
|
OK, I think this one is good to go now. The For reference: When locale is set to "C" we get ISO/IEC 9899:1999 5.2.1 Character sets:
|
A couple of warnings were uncovered in #6655
This should take care of the easy ones.
The larger problem is the ctype warnings where we have a bit of a mix between using the proper
isalnum()and rolling our own withgit__isalnum()The posix versions take an integer in to be able to handle EOF from
fgetc()so when a char is passed it has to be casted to unsigned so that 128-255 isn't extended to negative integers.The
git__isalnum()function takes care of it by simply not handling characters outside of the ascii set and will behave incorrectly on systems using ISO-8859-1 or other charsets using more than 7 bits.I'm not entirely sure why we have the
git__isalnum()functions. I assume it is to support systems wherectype.hisn't available?In that case I think the current implementation should be used only when ctype doesn't exists.
There is also the thing where casting characters to unsigned everywhere is a bit tedious, so maybe we should change the functions to take an unsigned char in?