kconfig: Fix warning: ignoring return value of 'fwrite'
PATCH 1/2 kconfig: Fix warning: ignoring return value of 'fwrite'
This fix facilitates fwrite() in both confdata.c and expr.c, either it succeeds in writing, or an error occurs, or the end of file is reached.
Signed-off-by Jean Sacren <[email protected]>
Cc stable <[email protected]>
--- scripts/kconfig/confdata.c | 6 +++--- scripts/kconfig/expr.c | 2 +- scripts/kconfig/lkc.h | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-)
scripts/kconfig/confdata.c +3 -3
@@ -505,7 +505,7 @@ int conf_write(const char *name)while (1 ) { l =strcspn (str,"\"\\" );if (l) { -fwrite (str, l,1 , out); +xfwrite (str, l,1 , out); str += l; }if (!*str)
@@ -756,8 +756,8 @@ int conf_write_autoconf(void)while (1 ) { 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)
scripts/kconfig/expr.c +1 -1
@@ -1087,7 +1087,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *static void expr_print_file_helper (void *data,struct symbol *sym,const char *str) { -fwrite (str,strlen (str),1 , data); +xfwrite (str,strlen (str),1 , data); }void expr_fprint (struct expr *e,FILE *out)
scripts/kconfig/lkc.h +7 -0
@@ -80,6 +80,13 @@ 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); +/* confdata.c and expr.c */ +static inline void xfwrite (const void *str,size_t len,size_t count,FILE *out) +{ +if (fwrite (str, len, count, out) < count) +fprintf (stderr,"\nError in writing or end of file.\n" ); +} +/* kconfig_load.c */ void kconfig_load (void );
Signature · 1 line
1.7.1
Quoted 10 lines · Jean Sacren
This fix facilitates
fwrite()in bothconfdata.candexpr.c, either it succeeds in writing, or an error occurs, or the end of file is reached.Signed-off-by Jean Sacren <[email protected]>Cc stable <[email protected]>--- scripts/kconfig/confdata.c | 6 +++--- scripts/kconfig/expr.c | 2 +- scripts/kconfig/lkc.h | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-)
I applied this and the second patch (sorry for the delay), but I dropped the Cc: stable line. It's just a warning, nothing critical, and the context is different in released kernels, so why bother Greg with manually resolving conflicts.
Michal