[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] Correct checks for dup failure in guestfs_launch



On Wed, Aug 19, 2009 at 10:57:40AM +0200, Jim Meyering wrote:
> The use of the |= operator might seem a little off-putting at
> first, but when you get used to the idiom and see the general benefit
> of fewer branches, and not having to "goto", maybe you'll prefer it.
> 
> diff --git a/src/guestfs.c b/src/guestfs.c
> index 0d54d65..53ef67d 100644
> --- a/src/guestfs.c
> +++ b/src/guestfs.c
> @@ -1166,8 +1166,8 @@ guestfs_launch (guestfs_h *g)
>      close (rfd[0]);
> 
>      int fail = 0;
> -    fail |= dup (wfd[0]);
> -    fail |= dup (rfd[1]);
> +    fail |= (dup (wfd[0]) < 0);
> +    fail |= (dup (rfd[1]) < 0);
>      close (wfd[0]);
>      close (rfd[1]);

I suggested something like this on IRC, but not well received ...

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]