kconfig: add fflush() before ferror() check
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 12 Feb 2022 16:18:37 +0000 (01:18 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Fri, 18 Feb 2022 02:33:35 +0000 (11:33 +0900)
As David Laight pointed out, there is not much point in calling
ferror() unless you call fflush() first.

Reported-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/confdata.c

index d3c3a61308adaecbfa77e8b79d71878adefd6fa2..94dcec2cc803f522941d38609a6235b40a3a1b89 100644 (file)
@@ -979,6 +979,7 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
 
        fprintf(out, "\n$(deps_config): ;\n");
 
+       fflush(out);
        ret = ferror(out); /* error check for all fprintf() calls */
        fclose(out);
        if (ret)
@@ -1097,6 +1098,7 @@ static int __conf_write_autoconf(const char *filename,
                if ((sym->flags & SYMBOL_WRITE) && sym->name)
                        print_symbol(file, sym);
 
+       fflush(file);
        /* check possible errors in conf_write_heading() and print_symbol() */
        ret = ferror(file);
        fclose(file);