From nobody Fri Nov 7 09:13:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154746076388074.6267349739569; Mon, 14 Jan 2019 02:12:43 -0800 (PST) Received: from localhost ([127.0.0.1]:34920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gizEY-0005E8-OK for importer@patchew.org; Mon, 14 Jan 2019 05:12:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giz4n-0005Xs-2s for qemu-devel@nongnu.org; Mon, 14 Jan 2019 05:02:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1giz4k-0007QQ-Uv for qemu-devel@nongnu.org; Mon, 14 Jan 2019 05:02:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1giz4j-0007N1-S9 for qemu-devel@nongnu.org; Mon, 14 Jan 2019 05:02:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C29B37E79; Mon, 14 Jan 2019 10:02:32 +0000 (UTC) Received: from thuth.com (ovpn-116-190.ams2.redhat.com [10.36.116.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED304101963C; Mon, 14 Jan 2019 10:02:30 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 14 Jan 2019 11:01:59 +0100 Message-Id: <1547460140-1473-5-git-send-email-thuth@redhat.com> In-Reply-To: <1547460140-1473-1-git-send-email-thuth@redhat.com> References: <1547460140-1473-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 14 Jan 2019 10:02:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock} 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Li Qiang Assert that the return value is not an error. This is like commit 7e6478e7d4f for qemu_set_cloexec. Signed-off-by: Li Qiang Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- 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 c1bee2a..4ce1ba9 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -233,14 +233,18 @@ void qemu_set_block(int fd) { int f; f =3D fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f !=3D -1); } =20 void qemu_set_nonblock(int fd) { int f; f =3D fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f !=3D -1); } =20 int socket_set_fast_reuse(int fd) --=20 1.8.3.1