Explorar o código

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: Jean Sacren <sakiwit@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Jean Sacren %!s(int64=15) %!d(string=hai) anos
pai
achega
4418a2b904
Modificáronse 2 ficheiros con 16 adicións e 2 borrados
  1. 13 2
      scripts/kconfig/conf.c
  2. 3 0
      scripts/kconfig/lkc.h

+ 13 - 2
scripts/kconfig/conf.c

@@ -108,7 +108,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
 		check_stdin();
 	case oldaskconfig:
 		fflush(stdout);
-		fgets(line, 128, stdin);
+		xfgets(line, 128, stdin);
 		return 1;
 	default:
 		break;
@@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu)
 			check_stdin();
 		case oldaskconfig:
 			fflush(stdout);
-			fgets(line, 128, stdin);
+			xfgets(line, 128, stdin);
 			strip(line);
 			if (line[0] == '?') {
 				print_help(menu);
@@ -644,3 +644,14 @@ int main(int ac, char **av)
 	}
 	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");
+}

+ 3 - 0
scripts/kconfig/lkc.h

@@ -72,6 +72,9 @@ void zconf_nextfile(const char *name);
 int zconf_lineno(void);
 char *zconf_curname(void);
 
+/* conf.c */
+void xfgets(char *str, int size, FILE *in);
+
 /* confdata.c */
 const char *conf_get_configname(void);
 const char *conf_get_autoconfig_name(void);