Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3816994pxj; Mon, 7 Jun 2021 22:27:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9Uqpqozjj0UF3Bggj84qsuVEyTU9iTTqLsp3qWbMJQtcyHnnrNajtKutCLZq1CYSZYdvG X-Received: by 2002:a17:906:48c8:: with SMTP id d8mr21890485ejt.176.1623130072385; Mon, 07 Jun 2021 22:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623130072; cv=none; d=google.com; s=arc-20160816; b=Yu+pJvsNgORiKll9NeSAAOhUclAPRP3NWHfk2+LEk5replGPIw7eu9zfkv2rnpHRJF 3Q4Nmi+Q1daP/SSg17yf90Vf5gWpgFsnM64tU8/VaOvHxgjNNNobADzZAQ22EmuinCW5 D66HDKJYASKlTksVdLewlLnXjP8aY5su3rTy467ItwS/+RFVJwP15GZVhTpkCvZ0c8II t1B9pmqkHA+9sRYqlxRh65T9zMFlc1ZwaPbMCeN6PuyUYKREMUjPBqbzEZLXtVfujS9y /9K41MYQoifDzKYQ24RoCt/S/DFCivQThMVc6RSXbde3y6rVUkUh3OYxUj0EJjobEwRu R9MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HgTYV9Px/yYsoJMHme0FF5gxjuYU1U+CkKemPJG//WI=; b=pYu/4Lk5U9egOYJD9RyMcJW2beMq2zDdVgbIbveTYtPngY+II39cisTE8Bzc8HqP6i 3DS1J5XPbJewNAzyI5636UGH0i/bZTgWj18OftgyZVUvbXh3J4qIYdKonYjmZ2jRINeR f2vT5ZDZZgA7earova2iBZpBO3+hstszB2IxNOK4gsFq4Xaubg6ywA2tU8Gfsn5M+t82 DQ2gJ3sekHKzDV47TTlf2YndNocwYRzKZE+dkzpvTVt7ufKmZLSIq8229BHn1yJHFk3E KoX9iym6PMNtkFsrI0cOyqMu9bo+k/3lh7qAHYweVZLgn1+D3354c+1PQbAFkxWNYmKj bCZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh16si14591271ejb.532.2021.06.07.22.27.28; Mon, 07 Jun 2021 22:27:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbhFHFZS (ORCPT + 99 others); Tue, 8 Jun 2021 01:25:18 -0400 Received: from verein.lst.de ([213.95.11.211]:49127 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbhFHFZQ (ORCPT ); Tue, 8 Jun 2021 01:25:16 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id E443E67373; Tue, 8 Jun 2021 07:23:20 +0200 (CEST) Date: Tue, 8 Jun 2021 07:23:20 +0200 From: Christoph Hellwig To: Wu Bo Cc: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linfeilong@huawei.com Subject: Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log() Message-ID: <20210608052320.GA13828@lst.de> References: <1623125616-629270-1-git-send-email-wubo40@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1623125616-629270-1-git-send-email-wubo40@huawei.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote: > - 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)) So besides making the code impossibl to read due to the incorrect indentation this also makes each WARN_ON_ONCE cover multiple conditions. Not very useful for debugging.