From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872A9C433F5 for ; Tue, 14 Sep 2021 07:44:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 096E66124C for ; Tue, 14 Sep 2021 07:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 096E66124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ37X-0004bY-0f for qemu-devel@archiver.kernel.org; Tue, 14 Sep 2021 03:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ36h-0003lZ-2P; Tue, 14 Sep 2021 03:43:55 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ36e-00083w-Bl; Tue, 14 Sep 2021 03:43:54 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H7wGb1ZsqzbmWd; Tue, 14 Sep 2021 15:39:35 +0800 (CST) Received: from kwepeml500004.china.huawei.com (7.221.188.141) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 14 Sep 2021 15:43:38 +0800 Received: from [10.174.187.138] (10.174.187.138) by kwepeml500004.china.huawei.com (7.221.188.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 14 Sep 2021 15:43:37 +0800 Message-ID: <614052A9.4060107@huawei.com> Date: Tue, 14 Sep 2021 15:43:37 +0800 From: Alex Chen User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Peter Maydell , Michael Tokarev Subject: Re: [PATCH V2] util: Remove redundant checks in the openpty() References: <5F9FE5B8.1030803@huawei.com> In-Reply-To: <5F9FE5B8.1030803@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.138] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepeml500004.china.huawei.com (7.221.188.141) X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.187; envelope-from=alex.chen@huawei.com; helo=szxga01-in.huawei.com X-Spam_score_int: -61 X-Spam_score: -6.2 X-Spam_bar: ------ X-Spam_report: (-6.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-1.969, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Trivial , yebiaoxiang@huawei.com, QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Hi all, This patch has been reviewed by Peter. who can help merge it? Thanks, Alex On 2020/11/2 18:55, AlexChen wrote: > As we can see from the following function call stack, amaster and aslave > can not be NULL: char_pty_open() -> qemu_openpty_raw() -> openpty(). > In addition, according to the API specification for openpty(): > https://www.gnu.org/software/libc/manual/html_node/Pseudo_002dTerminal-Pairs.html, > the arguments name, termp and winp can all be NULL, but arguments amaster or aslave > can not be NULL. > Finally, amaster and aslave has been dereferenced at the beginning of the openpty(). > So the checks on amaster and aslave in the openpty() are redundant. Remove them. > > Reported-by: Euler Robot > Signed-off-by: Alex Chen > Reviewed-by: Peter Maydell > --- > util/qemu-openpty.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c > index eb17f5b0bc..427f43a769 100644 > --- a/util/qemu-openpty.c > +++ b/util/qemu-openpty.c > @@ -80,10 +80,9 @@ static int openpty(int *amaster, int *aslave, char *name, > (termp != NULL && tcgetattr(sfd, termp) < 0)) > goto err; > > - if (amaster) > - *amaster = mfd; > - if (aslave) > - *aslave = sfd; > + *amaster = mfd; > + *aslave = sfd; > + > if (winp) > ioctl(sfd, TIOCSWINSZ, winp); >