From patchwork Fri Aug 31 18:16:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10584319 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 339415A4 for ; Fri, 31 Aug 2018 18:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22A712C5A1 for ; Fri, 31 Aug 2018 18:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15DC42C5A4; Fri, 31 Aug 2018 18:19:22 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY 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 B40A82C5A1 for ; Fri, 31 Aug 2018 18:19:21 +0000 (UTC) Received: from localhost ([::1]:56120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvo0v-0005f9-0Z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Aug 2018 14:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvnwI-0007Gi-RL for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvnwH-0005vs-5T for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:34 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvnwG-0005vV-Ur for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:33 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7VIDudm094223 for ; Fri, 31 Aug 2018 18:14:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=QNp9Gqcw4CYoto1SBRF18IVWZhes4hOn8Jls+CBfygg=; b=fYRkF9TPg0inwabDo5FDq72GweDmPqWCpg1w/QgyOmVEEInONDZhb8IKavpvsvISz9hR SyIBTLg9GsOEBUU0yK3T+FDQiqwiWkVan6bNZirQttiUUimz7+AJ4BcVtuB4pbcZ3VaX GewMUHyim2uLosieeG+qfgLgG3b0ZWrM6eKU1Plvgl9pvCOOEnvUmqewa0aETZYt8tiu 0TR25WIBysAPpwvAox/tA8gvjZG2bFIyzfwPeCyt/QBtO3ifxaV9YJUOiDtT+TQp9R2p sRHg7iO3BO38nq5olLUCLLX9zZBB40cggaUklEoNkVed7wBlvLNGRwJnD2pCTNEwSY8q Bg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2m2y2q4vjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:32 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7VIEVPk025987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:31 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7VIEVgH029612 for ; Fri, 31 Aug 2018 18:14:31 GMT Received: from ol7.nl.oracle.com (/10.175.61.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Aug 2018 11:14:30 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 31 Aug 2018 19:16:11 +0100 Message-Id: <1535739372-24454-8-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> References: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9001 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808310183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH v3 7/8] io: potential unnecessary check in qio_channel_command_new_spawn() 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In qio_channel_command_new_spawn() the 'flags' variable is checked to see if /dev/null should be used for stdin or stdout; first with O_RDONLY and then O_WRONLY. However the second check for O_WRONLY is only needed if flags != O_RDONLY and therefore should be an else if statement. This minor optimization has the added benefit of suppressing a warning from a static analysis tool (Parfait) which incorrectly reported an incorrect checking of flags in qio_channel_command_new_spawn() could result in an uninitialized file descriptor being used. Removing this noise will help us better find real issues. Signed-off-by: Liam Merwick Reviewed-by: Eric Blake --- io/channel-command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/io/channel-command.c b/io/channel-command.c index 3e7eb17eff54..82acd3234915 100644 --- a/io/channel-command.c +++ b/io/channel-command.c @@ -61,8 +61,7 @@ qio_channel_command_new_spawn(const char *const argv[], if (flags == O_RDONLY) { stdinnull = true; - } - if (flags == O_WRONLY) { + } else if (flags == O_WRONLY) { stdoutnull = true; }