diff mbox

[1/1] kconfig: Fix ignoring return value warning

Message ID alpine.LNX.2.00.1007112015260.4741@pobox.suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Jiri Kosina July 11, 2010, 6:17 p.m. UTC
None
diff mbox

Patch

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80..c6871d9 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -502,10 +502,10 @@  int conf_write(const char *name)
 			case S_STRING:
 				str = sym_get_string_value(sym);
 				fprintf(out, "CONFIG_%s=\"", sym->name);
-				while (1) {
+				for (;;) {
 					l = strcspn(str, "\"\\");
 					if (l) {
-						fwrite(str, l, 1, out);
+						xfwrite(str, l, 1, out);
 						str += l;
 					}
 					if (!*str)
@@ -753,11 +753,11 @@  int conf_write_autoconf(void)
 			str = sym_get_string_value(sym);
 			fprintf(out, "CONFIG_%s=\"", sym->name);
 			fprintf(out_h, "#define CONFIG_%s \"", sym->name);
-			while (1) {
+			for (;;) {
 				l = strcspn(str, "\"\\");
 				if (l) {
-					fwrite(str, l, 1, out);
-					fwrite(str, l, 1, out_h);
+					xfwrite(str, l, 1, out);
+					xfwrite(str, l, 1, out_h);
 					str += l;
 				}
 				if (!*str)
@@ -926,3 +926,15 @@  void conf_set_all_new_symbols(enum conf_def_mode mode)
 		csym->flags &= ~(SYMBOL_VALID);
 	}
 }
+/*
+ * Helper function to facilitate fwrite() by Jean Sacren.
+ */
+void xfwrite(xstr, len, count, output)
+	const void *xstr;
+	size_t len;
+	size_t count;
+	FILE *output;
+{
+	if (fwrite(xstr, len, count, output) < count)
+		fprintf(stderr, "\nError in writing.\n");
+}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index ce6549c..7d7061a 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -79,6 +79,7 @@  char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
 void conf_set_all_new_symbols(enum conf_def_mode mode);
+void xfwrite(const void *xstr, size_t len, size_t count, FILE *output);
 
 /* kconfig_load.c */
 void kconfig_load(void);