From patchwork Tue May 9 19:04:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 760304 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wMpjb6MtVz9ryb for ; Wed, 10 May 2017 05:05:39 +1000 (AEST) Received: from localhost ([::1]:38959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8AS1-0001hW-CY for incoming@patchwork.ozlabs.org; Tue, 09 May 2017 15:05:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8ART-0001gj-GW for qemu-devel@nongnu.org; Tue, 09 May 2017 15:05:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8ARQ-0001DU-7u for qemu-devel@nongnu.org; Tue, 09 May 2017 15:05:03 -0400 Received: from mail.kernel.org ([198.145.29.136]:43460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8ARQ-0001D9-2X for qemu-devel@nongnu.org; Tue, 09 May 2017 15:05:00 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F9DC20268; Tue, 9 May 2017 19:04:58 +0000 (UTC) Received: from localhost.localdomain (unknown [99.165.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 682F120219; Tue, 9 May 2017 19:04:57 +0000 (UTC) From: Stefano Stabellini To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 12:04:52 -0700 Message-Id: <1494356693-13190-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494356693-13190-1-git-send-email-sstabellini@kernel.org> References: <1494356693-13190-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PATCH v2 2/3] Check the return value of fcntl in qemu_set_cloexec 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: pbonzini@redhat.com, sstabellini@kernel.org, groug@kaod.org, xen-devel@lists.xen.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Assert that the return value is not an error. This issue was found by Coverity. CID: 1374831 Signed-off-by: Stefano Stabellini CC: groug@kaod.org CC: pbonzini@redhat.com CC: Eric Blake Reviewed-by: Eric Blake Reviewed-by: Greg Kurz --- util/oslib-posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4d9189e..16894ad 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -182,7 +182,9 @@ void qemu_set_cloexec(int fd) { int f; f = fcntl(fd, F_GETFD); - fcntl(fd, F_SETFD, f | FD_CLOEXEC); + assert(f != -1); + f = fcntl(fd, F_SETFD, f | FD_CLOEXEC); + assert(f != -1); } /*