changeset 12200:da69155ee914

Avoid warning despite dropping the return value of fwrite.
author Bruno Haible <bruno@clisp.org>
date Wed, 28 Oct 2009 00:51:42 +0100
parents 3fd611a409d1
children 96048aa0ade9
files ChangeLog lib/unicodeio.c modules/unicodeio
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-10-27  Jim Meyering  <jim@meyering.net>
+            Bruno Haible  <bruno@clisp.org>
+
+	Avoid warning despite dropping the return value of fwrite.
+	* lib/unicodeio.c: Include ignore-value.h.
+	(fwrite_success_callback): Explicitly ignore fwrite's return value.
+	* modules/unicodeio (Depends-on): Add ignore-value.
+
 2009-10-26  Eric Blake  <ebb9@byu.net>
 
 	areadlinkat: fix fallback path
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -1,6 +1,6 @@
 /* Unicode character output to streams with locale dependent encoding.
 
-   Copyright (C) 2000-2003, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2006, 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@
 
 #include "localcharset.h"
 #include "unistr.h"
+#include "ignore-value.h"
 
 /* When we pass a Unicode character to iconv(), we must pass it in a
    suitable encoding. The standardized Unicode encodings are
@@ -162,7 +163,11 @@
 {
   FILE *stream = (FILE *) callback_arg;
 
-  fwrite (buf, 1, buflen, stream);
+  /* The return value of fwrite can be ignored here, because under normal
+     conditions (STREAM is an open stream and not wide-character oriented)
+     when fwrite() returns a value != buflen it also sets STREAM's error
+     indicator.  */
+  ignore_value (fwrite (buf, 1, buflen, stream));
   return 0;
 }
 
--- a/modules/unicodeio
+++ b/modules/unicodeio
@@ -13,6 +13,7 @@
 gettext-h
 localcharset
 error
+ignore-value
 
 configure.ac:
 gl_UNICODEIO