From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujxlx-00014K-DV for qemu-devel@nongnu.org; Tue, 04 Jun 2013 16:24:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ujxls-0005py-N6 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 16:24:01 -0400 From: Alon Levy Date: Tue, 4 Jun 2013 16:23:36 -0400 Message-Id: <1370377419-31788-2-git-send-email-alevy@redhat.com> In-Reply-To: <1370377419-31788-1-git-send-email-alevy@redhat.com> References: <1370377419-31788-1-git-send-email-alevy@redhat.com> Subject: [Qemu-devel] [PATCH 2/5] use qemu_pipe_non_block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org This fixes six instances of unchecked fcntl return status, spotted by Coverity. Signed-off-by: Alon Levy --- hw/display/qxl.c | 10 +++------- hw/usb/ccid-card-emulated.c | 8 +++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 9e5b7ad..25c8c5a 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1797,15 +1797,11 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events) static void init_pipe_signaling(PCIQXLDevice *d) { - if (pipe(d->pipe) < 0) { - fprintf(stderr, "%s:%s: qxl pipe creation failed\n", - __FILE__, __func__); + if (qxl_pipe_non_block(d->pipe)) { + fprintf(stderr, "%s:%s: qxl pipe creation failed: %s\n", + __FILE__, __func__, stderror(errno)); exit(1); } - fcntl(d->pipe[0], F_SETFL, O_NONBLOCK); - fcntl(d->pipe[1], F_SETFL, O_NONBLOCK); - fcntl(d->pipe[0], F_SETOWN, getpid()); - qemu_thread_get_self(&d->main); qemu_set_fd_handler(d->pipe[0], pipe_read, NULL, d); } diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index deb6d47..2e6942e 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -406,13 +406,11 @@ static void pipe_read(void *opaque) static int init_pipe_signaling(EmulatedState *card) { - if (pipe(card->pipe) < 0) { - DPRINTF(card, 2, "pipe creation failed\n"); + if (qemu_pipe_non_block(card->pipe) < 0) { + DPRINTF(card, 2, "pipe creation failed: %s\n", + strerror(errno)); return -1; } - fcntl(card->pipe[0], F_SETFL, O_NONBLOCK); - fcntl(card->pipe[1], F_SETFL, O_NONBLOCK); - fcntl(card->pipe[0], F_SETOWN, getpid()); qemu_set_fd_handler(card->pipe[0], pipe_read, NULL, card); return 0; } -- 1.8.2.1