qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/5] oslib-posix: add qemu_pipe_n


From: Peter Maydell
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block
Date: Tue, 4 Jun 2013 21:48:59 +0100

On 4 June 2013 21:23, Alon Levy <address@hidden> wrote:
>
> +int qemu_pipe_non_block(int pipefd[2])
> +{
> +    int ret;
> +
> +    ret = qemu_pipe(pipefd);
> +    if (ret) {
> +        return ret;
> +    }
> +    if (fcntl(card->pipe[0], F_SETFL, O_NONBLOCK) == -1) {
> +        return -errno;
> +    }
> +    if (fcntl(card->pipe[1], F_SETFL, O_NONBLOCK) == -1) {
> +        return -errno;
> +    }

    qemu_set_nonblock(card->pipe[0]);
    qemu_set_nonblock(card->pipe[1]);

> +    if (fcntl(card->pipe[0], F_SETOWN, getpid()) == -1) {
> +        return -errno;
> +    }

You should either just trust that the fcntl() succeeds
(as we do in qemu_set_block() and friends), or you need
to close the pipe fds on failure here.

> +}

You've forgotten to return anything at the end of the function.
(surprised the compiler didn't pick that up, maybe it's
one of the warnings that needs optimimisation turned on).

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]