@@ -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");
+}
@@ -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);