- Notifications
You must be signed in to change notification settings - Fork2.5k
util: suppress some uninitialized variable warnings#6659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Also replaced index() with strchr(). index() isn't POSIX and won't compile on some systems. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
In C99 functions need to be declared before they are defined.We could just add the declarations before them, but including theheader 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.h
isn'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?