[Libguestfs] [libnbd PATCH v3 20/29] CONNECT_COMMAND.START: use symbolic constants for fd#0 and fd#1

Richard W.M. Jones rjones at redhat.com
Wed Feb 15 16:56:33 UTC 2023


On Wed, Feb 15, 2023 at 03:11:49PM +0100, Laszlo Ersek wrote:
> Refer to fd#0 and fd#1 with the symbolic constants STDIN_FILENO and
> STDOUT_FILENO from <unistd.h>, for better readability.
> 
> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
> ---
>  generator/states-connect.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/generator/states-connect.c b/generator/states-connect.c
> index 83d7f316828e..f0020d6f3b26 100644
> --- a/generator/states-connect.c
> +++ b/generator/states-connect.c
> @@ -260,11 +260,11 @@  CONNECT_COMMAND.START:
>      return 0;
>    }
>    if (pid == 0) {         /* child - run command */
> -    close (0);
> -    close (1);
> +    close (STDIN_FILENO);
> +    close (STDOUT_FILENO);
>      close (sv[0]);
> -    dup2 (sv[1], 0);
> -    dup2 (sv[1], 1);
> +    dup2 (sv[1], STDIN_FILENO);
> +    dup2 (sv[1], STDOUT_FILENO);
>      close (sv[1]);

Reviewed-by: Richard W.M. Jones <rjones at redhat.com>


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v


More information about the Libguestfs mailing list