In my C application I attempt to take in a single char from a user (no need to sanitize it) for commands. Functions such as getchar(), fgetc(stdin), and scanf(...) all give me the following error when used with coverity: Event dereference: Dereferencing "_stdin()", which is known to be "NULL". I use aggressiveness-level set to medium for the coverity-analyze command.
For example, I have tried checking cAck against NULL, stdin against NULL, ferror(stdin), against EOF, and feof(stdin) before using the cAck variable (Edit: I had tried without any of these checks and coverity still complained). How would I make something like the following run without coverity complaints?
char cAck;
if( (cAck = fgetc(stdin)) != NULL)
{
// do something with cAck
}