From: Jim Meyering Date: Fri, 19 Oct 2007 20:11:17 +0000 (+0200) Subject: * lib/xprintf.c (xprintf, xfprintf): Test err < 0, not just "err". X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9d370720f15fe910f40603a734f67e28b261cc2;p=pspp * lib/xprintf.c (xprintf, xfprintf): Test err < 0, not just "err". --- diff --git a/ChangeLog b/ChangeLog index ede13c3f14..d837fc11c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2007-10-19 Jim Meyering + * lib/xprintf.c (xprintf, xfprintf): Test err < 0, not just "err". + New module: xprintf * modules/xprintf, lib/xprintf.c, lib/xprintf.h: New files. diff --git a/lib/xprintf.c b/lib/xprintf.c index a01eff8cdd..908fc4f11e 100644 --- a/lib/xprintf.c +++ b/lib/xprintf.c @@ -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;