From patchwork Fri Aug 31 16:36:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 964567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="2wX58cO8"; dkim-atps=neutral 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 4224kD4W07z9s3C for ; Sat, 1 Sep 2018 02:36:20 +1000 (AEST) Received: from localhost ([::1]:54985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvmPB-000117-K1 for incoming@patchwork.ozlabs.org; Fri, 31 Aug 2018 12:36:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvmOP-0000zw-LP for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvmOL-0005CC-Mu for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvmOH-00053w-Rz for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7VGYL9u153589 for ; Fri, 31 Aug 2018 16:35:17 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=h0lboUktKnwdJu3Ig0zoJj6r6IritbqAD7ZH8duFafQ=; b=2wX58cO86VImWSKwNxNnqsuB2Q3BGrvb8pH0iH4Jv3nUpCnxzyxA3bsHB9oHzcyjszj+ dNyn2KxgqVX6wjRap1FaeX268k9YTlkm1HlFpfM6jdFgSzeyDt0AJfFUfEIngv1SqBvN LqE/K7TKp/DbhZ/U1nwTiFcnkeO/2RIfPvFe5a2/e7iJ+Ca4ETLsYog1tMG34tZl7rLN mLGD8k4QIxDAWLK3WcZnwrikJXCe/lfpWRO81cDRR1O0bfP12JpH9WD7auETsbLoB7uy 9aJ3lhWfwHXJnITWROdJMX3XfAcUwIr+Bsmsy7e/kUoHNYWKdRUUFJAwy89e09aHu1H0 cw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2m2xhuceu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 16:35:17 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7VGZGh3020054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 16:35:16 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7VGZFNw007203 for ; Fri, 31 Aug 2018 16:35:16 GMT Received: from ol7.nl.oracle.com (/10.175.61.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Aug 2018 09:35:15 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 31 Aug 2018 17:36:53 +0100 Message-Id: <1535733414-6812-8-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535733414-6812-1-git-send-email-Liam.Merwick@oracle.com> References: <1535733414-6812-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-1808310170 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v2 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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; }