Examples of errors detected by the V739 diagnostic


V739. EOF should not be compared with a value of the 'char' type. Consider using the 'int' type.


Computational Network Toolkit

V739 EOF should not be compared with a value of the 'char' type. The 'c' should be of the 'int' type. fileutil.cpp 852


string fgetstring(FILE* f)
{
  string res;
  for (;;)
  {
    char c = (char) fgetc(f);        // <=
    if (c == EOF)                    // <=
      RuntimeError("error reading .... 0: %s", strerror(errno));
    if (c == 0)
      break;
    res.push_back(c);
  }
  return res;
}

Android

V739 CWE-20 EOF should not be compared with a value of the 'char' type. The '(c = fgetc(blk_alloc_file))' should be of the 'int' type. blk_alloc_to_base_fs.c 61


int main(int argc, char **argv)
{
  ....
  char c;
  printf("%s is already in *.base_fs format, just copying ....);
  rewind(blk_alloc_file);
  while ((c = fgetc(blk_alloc_file)) != EOF) {
    fputc(c, base_fs_file);
  }
  ....
}

NCBI Genome Workbench

V739 EOF should not be compared with a value of the 'char' type. The 'linestring[0]' should be of the 'int' type. alnread.c 3509


static EBool
s_AfrpInitLineData(
  ....
  char* linestring = readfunc (pfile);
  ....
  while (linestring != NULL  &&  linestring [0] != EOF) {
    s_TrimSpace (&linestring);
    ....
  }
  ....
}


Bugs Found

Checked Projects
336
Collected Errors
12 743