Skip to content

Commit

Permalink
Prevent warning: ignoring return value of ‘fgets’
Browse files Browse the repository at this point in the history
..., declared with attribute warn_unused_result [-Wunused-result]
  • Loading branch information
lmoellendorf committed May 14, 2024
1 parent 637daf9 commit e65fc0a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/test_iniparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ void Test_iniparser_dump(CuTest *tc)
dictionary *dic;
FILE *fp = NULL;
char buff[255];
char *ret;

/*loading old.ini*/
dic = iniparser_load(OLD_INI_PATH);
Expand Down Expand Up @@ -887,20 +888,23 @@ void Test_iniparser_dump(CuTest *tc)
printf("error: test.txt is not exist");
exit(-1);
}
fgets(buff,100,fp);
ret = fgets(buff,100,fp);
(void)ret;
/*remove '\n'*/
if(buff[strlen(buff)-1] == '\n')
{
buff[strlen(buff)-1] = '\0';
}
CuAssertStrEquals(tc,"[section]=UNDEF",buff);
fgets(buff,100,fp);
ret = fgets(buff,100,fp);
(void)ret;
if(buff[strlen(buff)-1] == '\n')
{
buff[strlen(buff)-1] = '\0';
}
CuAssertStrEquals(tc,"[section:key_01]=[hello world]",buff);
fgets(buff,100,fp);
ret = fgets(buff,100,fp);
(void)ret;
if(buff[strlen(buff)-1] == '\n')
{
buff[strlen(buff)-1] = '\0';
Expand Down

0 comments on commit e65fc0a

Please sign in to comment.