Skip to content

Commit e65fc0a

Browse files
committed
Prevent warning: ignoring return value of ‘fgets’
..., declared with attribute warn_unused_result [-Wunused-result]
1 parent 637daf9 commit e65fc0a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/test_iniparser.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ void Test_iniparser_dump(CuTest *tc)
858858
dictionary *dic;
859859
FILE *fp = NULL;
860860
char buff[255];
861+
char *ret;
861862

862863
/*loading old.ini*/
863864
dic = iniparser_load(OLD_INI_PATH);
@@ -887,20 +888,23 @@ void Test_iniparser_dump(CuTest *tc)
887888
printf("error: test.txt is not exist");
888889
exit(-1);
889890
}
890-
fgets(buff,100,fp);
891+
ret = fgets(buff,100,fp);
892+
(void)ret;
891893
/*remove '\n'*/
892894
if(buff[strlen(buff)-1] == '\n')
893895
{
894896
buff[strlen(buff)-1] = '\0';
895897
}
896898
CuAssertStrEquals(tc,"[section]=UNDEF",buff);
897-
fgets(buff,100,fp);
899+
ret = fgets(buff,100,fp);
900+
(void)ret;
898901
if(buff[strlen(buff)-1] == '\n')
899902
{
900903
buff[strlen(buff)-1] = '\0';
901904
}
902905
CuAssertStrEquals(tc,"[section:key_01]=[hello world]",buff);
903-
fgets(buff,100,fp);
906+
ret = fgets(buff,100,fp);
907+
(void)ret;
904908
if(buff[strlen(buff)-1] == '\n')
905909
{
906910
buff[strlen(buff)-1] = '\0';

0 commit comments

Comments
 (0)