Address ignored return value warnings in chkfont

Actually verify return values of fgets() and fscanf() in chkfont instead
of disabling the warning.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka 2011-01-11 17:54:24 -02:00
parent 7981f92538
commit f926ed97ac
2 changed files with 17 additions and 3 deletions

View File

@ -20,7 +20,7 @@ SHELL = /bin/sh
# The C compiler and linker to use
CC = gcc
CFLAGS = -g -O2 -Wall -Wno-unused-result
CFLAGS = -g -O2 -Wall
LD = gcc
LDFLAGS =

View File

@ -108,15 +108,24 @@ exit(1);
/* Don't warn on unitialized expected_width and expected_endmark */
#pragma GCC diagnostic ignored "-Wuninitialized"
/* Don't warn on unused return values of fgets() and fscanf() */
#pragma GCC diagnostic ignored "-Wuninitialized"
void readchar()
{
int i,expected_width,k,len,newlen,diff,l;
char endmark,expected_endmark;
int leadblanks,minleadblanks,trailblanks,mintrailblanks;
char *ret;
for (i=0;i<charheight;i++) {
fgets(fileline,maxlen+1000,fontfile);
ret = fgets(fileline,maxlen+1000,fontfile);
if (ret == NULL) {
printf("%s: ERROR (fatal)- Unexpected read error after line %d.\n",
fontfilename,currline);
ec++;
weregone(1); if (gone) return;
}
if (feof(fontfile)) {
printf("%s: ERROR (fatal)- Unexpected end of file after line %d.\n",
fontfilename,currline);
@ -240,7 +249,12 @@ if (fontfile!=stdin) {
weregone(0); if (gone) return;
}
}
fscanf(fontfile,"%4s",magicnum);
numsread=fscanf(fontfile,"%4s",magicnum);
if (numsread == EOF) {
printf("%s: ERROR- can't read magic number.\n",fontfilename);
ec++;
weregone(0); if (gone) return;
}
if (strcmp(magicnum,FONTFILEMAGICNUMBER)) {
printf("%s: ERROR- Incorrect magic number.\n",fontfilename);
ec++;