Skip to content

Commit

Permalink
kconfig: Fix warning: ignoring return value of 'fwrite'
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
sacren authored and michal42 committed Aug 12, 2010
1 parent 866af40 commit bf5e327
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static void conf_write_string(bool headerfile, const char *name,
while (1) {
l = strcspn(str, "\"\\");
if (l) {
fwrite(str, l, 1, out);
xfwrite(str, l, 1, out);
str += l;
}
if (!*str)
Expand Down
2 changes: 1 addition & 1 deletion scripts/kconfig/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit bf5e327

Please sign in to comment.