All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Sacren <sakiwit@gmail.com>
To: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>,
	Roman Zippel <zippel@linux-m68k.org>,
	linux-kbuild@vger.kernel.org
Subject: [PATCH 1/2] kconfig: Fix warning: ignoring return value of 'fwrite'
Date: Wed, 4 Aug 2010 16:01:02 -0600	[thread overview]
Message-ID: <20100804220102.GA10534@mail.gmail.com> (raw)

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 <sakiwit@gmail.com>
Cc: stable <stable@kernel.org>
---
 scripts/kconfig/confdata.c |    6 +++---
 scripts/kconfig/expr.c     |    2 +-
 scripts/kconfig/lkc.h      |    7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80..0fe158c 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -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)
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index d83f232..b5c47e1 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -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)
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index ce6549c..90fe55a 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -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);
 
-- 
1.7.1

             reply	other threads:[~2010-08-04 22:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04 22:01 Jean Sacren [this message]
2010-08-12 22:50 ` [PATCH 1/2] kconfig: Fix warning: ignoring return value of 'fwrite' Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100804220102.GA10534@mail.gmail.com \
    --to=sakiwit@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.