Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3770531pxj; Mon, 7 Jun 2021 20:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzjtW899I6bPEtD4a3MGZqreRRll7iEVcEgGXzYYlFuMOa2JLComIs4Ia7BaiC3hZcoKg+ X-Received: by 2002:a05:6402:10cc:: with SMTP id p12mr23602430edu.328.1623124218688; Mon, 07 Jun 2021 20:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623124218; cv=none; d=google.com; s=arc-20160816; b=yLjnzO27BK7fI4QZYzKhgRn/IARAGUuHp01/MGkhrRcjLAjjmcEpYoXXgpznMKQGiP da7U8dr7PeOWzfBZN+aPqXwWbATMli1QyImBCRofmtyEO8DJiODYVAZnrqINi9x7G4l5 UodGHBbvlJgn3Lp7xPMXo12nqcNTlQqb/dA+8Kj1NCjOyDvrk23bFLcFehcfwcwmIJxj 2ASF4yAAJsqfvVGh8VmGN1qX/uzTHa2oBPZNa8XqBad/KBlHr+grnsKgQYTs+LQq0lLj iOzpg0fh75IIGruSnghziVDB7RsKRzDqf7dVi9z6NcvnqpUFJgx4yHS5P9bTBoqCUOPi Hurg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=WMgql+b8zpFFHpjudZ9G6gYOlPfOuG36h4CQp0qP/Uc=; b=RGdsHNOMLIWQbYoE5ZU+IYoJAdEMVZ3WOy7hpmFefQor1MPwyvm0zFBsV5m+VDMnFc eghzCB1ilVEqG6et+nMQ3Vet1+jjwP98Sb0Fk59eGCLNKtN+tzHbkt+thOuWSNjqAwBU nQJZ1eDm4w3bDhGDl0jpkCnRKsgoNP6gPndhglJs5QH06PV10tY9Q5V+pMl42VJ+Yxn8 cS1hh9VI35YKk6c0lOUCipHXVVORSZSQ9TJKmZc6FPMJn8PU2iOdIm+KHPi/nvboea6E wAvkACXlRB+kw1qpmB3puX/w0jKMXmE7wsCepGiA6cvK094x4h4lqY4XpRtNxW94O3Ew ZC2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si14157691ejo.445.2021.06.07.20.49.55; Mon, 07 Jun 2021 20:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbhFHDrx (ORCPT + 99 others); Mon, 7 Jun 2021 23:47:53 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:4392 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbhFHDrx (ORCPT ); Mon, 7 Jun 2021 23:47:53 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Fzbdr4sCPz6vFb; Tue, 8 Jun 2021 11:42:08 +0800 (CST) Received: from dggpeml500019.china.huawei.com (7.185.36.137) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 11:45:59 +0800 Received: from huawei.com (10.175.124.27) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 11:45:58 +0800 From: Wu Bo To: , , , , , CC: , Subject: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log() Date: Tue, 8 Jun 2021 12:13:36 +0800 Message-ID: <1623125616-629270-1-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500019.china.huawei.com (7.185.36.137) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Combine grpid and ANA state checks in nvme_parse_ana_log() to reduce repetitive code and more intuitive meaning. Signed-off-by: Wu Bo --- drivers/nvme/host/multipath.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index f81871c..19fe16d 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -522,13 +522,11 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data, nr_nsids = le32_to_cpu(desc->nnsids); nsid_buf_size = nr_nsids * sizeof(__le32); - if (WARN_ON_ONCE(desc->grpid == 0)) + if (WARN_ON_ONCE(desc->grpid == 0 || + le32_to_cpu(desc->grpid) > ctrl->anagrpmax)) return -EINVAL; - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax)) - return -EINVAL; - if (WARN_ON_ONCE(desc->state == 0)) - return -EINVAL; - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE)) + if (WARN_ON_ONCE(desc->state == 0 || + desc->state > NVME_ANA_CHANGE)) return -EINVAL; offset += sizeof(*desc); -- 2.30.2