From patchwork Tue Jun 4 20:23:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 248853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B1E1F2C009D for ; Wed, 5 Jun 2013 06:24:31 +1000 (EST) Received: from localhost ([::1]:58291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjxmP-0001C8-Ow for incoming@patchwork.ozlabs.org; Tue, 04 Jun 2013 16:24:29 -0400 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 Received: from mx1.redhat.com ([209.132.183.28]:21152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujxls-0005pq-EW; Tue, 04 Jun 2013 16:23:56 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r54KNtwx009116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Jun 2013 16:23:55 -0400 Received: from garlic.sbx07344.newyony.wayport.net (vpn1-5-107.ams2.redhat.com [10.36.5.107]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r54KNeZg022345; Tue, 4 Jun 2013 16:23:52 -0400 From: Alon Levy To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/5] use qemu_pipe_non_block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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; }