This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH, libiberty: eliminate build warning
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: binutils <binutils at sourceware dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: ian at airs dot com, dj at redhat dot com
- Date: Thu, 19 Nov 2009 21:19:35 +1100
- Subject: PATCH, libiberty: eliminate build warning
This patch eliminates a warning in pex-unix.c due to write(3) being
marked as warn_unused_result on some GNU/Linux distributions. As the
coment in pex_child_error says, there is no alternative such as using
fwrite(3).
Okay for binutils and gcc trunk?
Thanks, Ben
2009-11-19 Ben Elliston <bje@au.ibm.com>
* pex-unix.c (pex_child_error): Define writeerr macro to avoid
unused result warnings from write(3) calls. Undefine writeerr
after all uses.
Index: pex-unix.c
===================================================================
RCS file: /cvs/src/src/libiberty/pex-unix.c,v
retrieving revision 1.14
diff -u -p -r1.14 pex-unix.c
--- pex-unix.c 27 Jul 2009 19:01:17 -0000 1.14
+++ pex-unix.c 19 Nov 2009 10:09:16 -0000
@@ -368,7 +368,7 @@ static void
pex_child_error (struct pex_obj *obj, const char *executable,
const char *errmsg, int err)
{
-#define writeerr(s) (void) write (STDERR_FILE_NO, s, strlen (s))
+#define writeerr(s) if (write (STDERR_FILE_NO, s, strlen (s))) {}
writeerr (obj->pname);
writeerr (": error trying to exec '");
writeerr (executable);
@@ -377,6 +377,7 @@ pex_child_error (struct pex_obj *obj, co
writeerr (": ");
writeerr (xstrerror (err));
writeerr ("\n");
+#undef writeerr
_exit (-1);
}