提交 4418a2b9 编写于 作者: J Jean Sacren 提交者: Michal Marek

kconfig: Fix warning: ignoring return value of 'fgets'

This fix facilitates fgets() either it returns on success or on error or
when end of file occurs.
Signed-off-by: NJean Sacren <sakiwit@gmail.com>
Signed-off-by: NMichal Marek <mmarek@suse.cz>
上级 bf5e327a
...@@ -108,7 +108,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) ...@@ -108,7 +108,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
check_stdin(); check_stdin();
case oldaskconfig: case oldaskconfig:
fflush(stdout); fflush(stdout);
fgets(line, 128, stdin); xfgets(line, 128, stdin);
return 1; return 1;
default: default:
break; break;
...@@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu) ...@@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu)
check_stdin(); check_stdin();
case oldaskconfig: case oldaskconfig:
fflush(stdout); fflush(stdout);
fgets(line, 128, stdin); xfgets(line, 128, stdin);
strip(line); strip(line);
if (line[0] == '?') { if (line[0] == '?') {
print_help(menu); print_help(menu);
...@@ -644,3 +644,14 @@ int main(int ac, char **av) ...@@ -644,3 +644,14 @@ int main(int ac, char **av)
} }
return 0; return 0;
} }
/*
* Helper function to facilitate fgets() by Jean Sacren.
*/
void xfgets(str, size, in)
char *str;
int size;
FILE *in;
{
if (fgets(str, size, in) == NULL)
fprintf(stderr, "\nError in reading or end of file.\n");
}
...@@ -72,6 +72,9 @@ void zconf_nextfile(const char *name); ...@@ -72,6 +72,9 @@ void zconf_nextfile(const char *name);
int zconf_lineno(void); int zconf_lineno(void);
char *zconf_curname(void); char *zconf_curname(void);
/* conf.c */
void xfgets(char *str, int size, FILE *in);
/* confdata.c */ /* confdata.c */
const char *conf_get_configname(void); const char *conf_get_configname(void);
const char *conf_get_autoconfig_name(void); const char *conf_get_autoconfig_name(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册