* lib/xprintf.c (xprintf, xfprintf): Test err < 0, not just "err".
authorJim Meyering <meyering@redhat.com>
Fri, 19 Oct 2007 20:11:17 +0000 (22:11 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 19 Oct 2007 20:11:17 +0000 (22:11 +0200)
ChangeLog
lib/xprintf.c

index ede13c3..d837fc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2007-10-19  Jim Meyering  <meyering@redhat.com>
 
+       * lib/xprintf.c (xprintf, xfprintf): Test err < 0, not just "err".
+
        New module: xprintf
        * modules/xprintf, lib/xprintf.c, lib/xprintf.h: New files.
 
index a01eff8..908fc4f 100644 (file)
@@ -37,7 +37,7 @@ xprintf (char const *restrict format, ...)
   va_list args;
   va_start (args, format);
   int err = vprintf (format, args);
-  if (err && (errno == EILSEQ || errno == EINVAL || errno == ENOMEM))
+  if (err < 0 && (errno == EILSEQ || errno == EINVAL || errno == ENOMEM))
     error (exit_failure, errno, gettext ("write error"));
 
   return err;
@@ -51,7 +51,7 @@ xfprintf (FILE *restrict stream, char const *restrict format, ...)
   va_list args;
   va_start (args, format);
   int err = vfprintf (stream, format, args);
-  if (err && (errno == EILSEQ || errno == EINVAL || errno == ENOMEM))
+  if (err < 0 && (errno == EILSEQ || errno == EINVAL || errno == ENOMEM))
     error (exit_failure, errno, gettext ("write error"));
 
   return err;