Avoid warning despite dropping the return value of fwrite.
authorBruno Haible <bruno@clisp.org>
Tue, 27 Oct 2009 23:51:42 +0000 (00:51 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 27 Oct 2009 23:52:36 +0000 (00:52 +0100)
ChangeLog
lib/unicodeio.c
modules/unicodeio

index 0897109..20c0e56 100644 (file)
--- 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
index 781621c..b6fd658 100644 (file)
@@ -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 @@ fwrite_success_callback (const char *buf, size_t buflen, void *callback_arg)
 {
   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;
 }
 
index 45be9fd..8231569 100644 (file)
@@ -13,6 +13,7 @@ iconv_open
 gettext-h
 localcharset
 error
+ignore-value
 
 configure.ac:
 gl_UNICODEIO