From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73416A0A0E; Thu, 29 Apr 2021 02:43:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E91594112A; Thu, 29 Apr 2021 02:43:28 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 95C9740697 for ; Thu, 29 Apr 2021 02:43:26 +0200 (CEST) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4FVxVS2cj5z5vYv for ; Thu, 29 Apr 2021 08:40:16 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 29 Apr 2021 08:43:24 +0800 To: "Pattan, Reshma" , "dev@dpdk.org" CC: "Yigit, Ferruh" , "Hunt, David" References: <1619355594-15223-1-git-send-email-humin29@huawei.com> From: "Min Hu (Connor)" Message-ID: Date: Thu, 29 Apr 2021 08:43:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] lib/librte_power: fix using variables before validity check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" ÔÚ 2021/4/28 23:13, Pattan, Reshma дµÀ: > > >> -----Original Message----- >> From: dev On Behalf Of Min Hu (Connor) >> >> + if (lcore_id >= RTE_MAX_LCORE) { >> + RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range >> 0...%d\n", >> + lcore_id, RTE_MAX_LCORE-1); >> + return -1; >> + } >> + > > This looks good. > >> fds.fd = global_fds[lcore_id]; >> fds.events = POLLIN; >> > > >> if (global_fds[lcore_id] < 0) { >> RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not >> connected\n"); > > > Another suggestion if you would like to improve the code, is below, > You can move "global_fds[lcore_id]" check to immediate after the line "fds.fd = global_fds[lcore_id]; " Hi, thanks Pattan. But I think "global_fds[lcore_id]" check may move before the line "fds.fd = global_fds[lcore_id]; If it failed, "fds.fd = global_fds[lcore_id];" should not be performed. What's your opinion? > > Reviewed-by: Reshma Pattan > > . >