[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
- Re: [Qemu-trivial] [Qemu-devel] [PATCH 2/5] use qemu_pipe_non_block, (continued)
- [Qemu-trivial] [PATCH 3/5] libcacard/vscclient: fix leakage of socket on error paths, Alon Levy, 2013/06/04
- [Qemu-trivial] [PATCH 4/5] libcacard/vreader.c: fix possible NULL dereference, Alon Levy, 2013/06/04
- [Qemu-trivial] [PATCH 5/5] libcacard/vscclient.c: fix use of uninitialized variable, Alon Levy, 2013/06/04
- Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block,
Peter Maydell <=
- Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block, Eric Blake, 2013/06/04
- Re: [Qemu-trivial] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block, Michael Tokarev, 2013/06/05
- Re: [Qemu-trivial] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block, Michael Tokarev, 2013/06/12