On 4 June 2013 21:23, Alon Levy <[email protected]> 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