avoid more undefined handler
PATCH 1/1 avoid more undefined handler
Clang also warned about this:
ANALYZE: eval.c evalpipe
eval.c:575:10: warning: Assigned value is garbage or undefined
prevfd = pip[0];
^ ~~~~~~
Here's a fix:
2011-05-25 Jim Meyering <[email protected]>
avoid more undefined handler
* src/eval.c (evalpipe): Ensure that pip[0] is defined before used.
From dca635b44d289eeb6b7d0fb6a60db37fb61bc863 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Wed, 25 May 2011 14:35:24 +0200
Subject: [PATCH] avoid more undefined handler
* src/eval.c (evalpipe): Ensure that pip[0] is defined before used.
--- src/eval.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)
src/eval.c +1 -0
@@ -547,6 +547,7 @@ evalpipe(union node *n, int flags) prevfd =-1 ;for (lp = n->npipe.cmdlist ; lp ; lp = lp->next) {prehash (lp->n); + pip[0 ] =-1 ; pip[1 ] =-1 ;if (lp->next) {if (pipe (pip) <0 ) {
--
1.7.5.2.609.g6dbbf
Quoted 6 lines · Jim Meyering
Clang also warned about this:
ANALYZE:
eval.cevalpipe
eval.c:575:10: warning: Assigned value is garbage or undefined
prevfd = pip[0];
^ ~~~~~~
This isn't really a bug. If pip[0] is garbage at this point, then we're the last element in a pipeline and prevfd will never be used again.
If you can think of a way of solving this without adding to the code size then I'll gladly apply it :)
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt