From patchwork Thu Dec 13 02:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10727535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB7D56C5 for ; Thu, 13 Dec 2018 02:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BA582B98B for ; Thu, 13 Dec 2018 02:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 902052B98C; Thu, 13 Dec 2018 02:10:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B28D2B98A for ; Thu, 13 Dec 2018 02:10:30 +0000 (UTC) Received: from localhost ([::1]:49911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXGSL-0001oh-4C for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Dec 2018 21:10:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXGRg-0001ms-Hs for qemu-devel@nongnu.org; Wed, 12 Dec 2018 21:09:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXGRd-0007qN-9d for qemu-devel@nongnu.org; Wed, 12 Dec 2018 21:09:48 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:38073) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXGRc-0007p1-UA for qemu-devel@nongnu.org; Wed, 12 Dec 2018 21:09:45 -0500 Received: by mail-pf1-x444.google.com with SMTP id q1so268969pfi.5 for ; Wed, 12 Dec 2018 18:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=kuwFIzvENBydeg1EpaW3bWLcJd16XTwtySU69eqjqss=; b=FA2lc467PXP71fSIHYeADumfJeQo7utO/nui8Z3qekAKUuIvn3uORbwI1dXwVzOU8B et06s8NiTeAeMhVBO4wAGyM+9b5UlqvT76PnaNH2KSIyQRGMLm8Wbz7QNqH4Mmljlgn+ zLr1AgIwwlpLAst/TaDpDreBwjOc5ujzUkQDn3wYoauhH3rxVaHq5pbVBwnDMj1/VA9q zF6izVyPYQRAwouaqfQ8NwEZFg6Zbfo5ds8fVk9AMQTw8NOVh3LoqMu0gNoNTTxrzNUM WMwl5ljPjUyTQGhGEEl6lGauGCcvzr4OIDQ76DoSlvrcpsDO3AR1U2zUUA6yAkbtfIQ9 hpfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kuwFIzvENBydeg1EpaW3bWLcJd16XTwtySU69eqjqss=; b=Yt/+Q06Ee0+BMt4ZbRZRY/aYd/j0uraZkD5FnF/AUuPryytTDnGMKDZPpfl6mmc3HR 4HIwfzhUmqoauxrQvU+ifeuHkNhxU+3rfe5HsqnIK0WZKdYETlJPBnbs7oSkRnTqe1N5 aAyrGEHrYY+iHUkLvRriHtDjejltUVagidxRY5SDLVc5Pg4wLnzxzSVlXXvFc4zcMu+D BKX5wl9tJsiIEFsFKEGjRl4cNKzmPqcG+CHKRHbtudDvGRGfC0TEWeKcV4IZ9Vo/8i3x 4Fj3GjibmqcMu7Cg2laiUVvJAFUoDhWAG6EEDw2WmLIXUdvgluv7UkeYHYUI39fQZUZ8 KjHg== X-Gm-Message-State: AA+aEWY+/JHPhCV+4ro17lYc3t+JxZv6bBvh3r/76jmp41jbZcZc+Pgh rreeM9BS13+Tm8KsNmQySnM= X-Google-Smtp-Source: AFSGD/V8cjqckx2m2GKBVam2/yaR5MoFE0NKvxwkwpe/zvwCBkUHQzU6Hfze6nfyAnERfj7GttUV+w== X-Received: by 2002:a62:c21c:: with SMTP id l28mr22216265pfg.74.1544666983726; Wed, 12 Dec 2018 18:09:43 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id v191sm353541pgb.77.2018.12.12.18.09.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 18:09:43 -0800 (PST) From: Li Qiang To: peter.maydell@linaro.org, marcandre.lureau@redhat.com, pbonzini@redhat.com Date: Wed, 12 Dec 2018 18:09:37 -0800 Message-Id: <1544666977-4816-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Assert that the return value is not an error. This is like commit 7e6478e7d4f for qemu_set_cloexec. Signed-off-by: Li Qiang --- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index c1bee2a581..4ce1ba9ca4 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -233,14 +233,18 @@ void qemu_set_block(int fd) { int f; f = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f != -1); + f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f != -1); } void qemu_set_nonblock(int fd) { int f; f = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f != -1); + f = fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f != -1); } int socket_set_fast_reuse(int fd)