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 6FFE4A034F; Tue, 11 Jan 2022 15:55:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02A624272A; Tue, 11 Jan 2022 15:55:04 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 9C2AA41143 for ; Tue, 11 Jan 2022 15:55:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641912902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K8dxxzp/IgVA+OcTNibZVThvV2V8CjCH701ci5TFd5M=; b=jMp9IznxrAPULqKET08sqezHEKUfrFeNgGtjSDhnYqr9ferCxm9doxVtY+Z/Bpv5QylPKd 5FIu26t7tYUhF4K7ZY40gMryCmYzgVE7o7pyR7UBsCrA9j3IVKMeIg1d+RxJHGRFZcB3Pm EQ7Dmo97vf13dFnnajnQpGwQCKoMlOQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-E7bG3XRYMsaXZKFpoFQlfA-1; Tue, 11 Jan 2022 09:55:00 -0500 X-MC-Unique: E7bG3XRYMsaXZKFpoFQlfA-1 Received: by mail-wm1-f70.google.com with SMTP id i81-20020a1c3b54000000b003467c58cbddso1668981wma.5 for ; Tue, 11 Jan 2022 06:55:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=K8dxxzp/IgVA+OcTNibZVThvV2V8CjCH701ci5TFd5M=; b=v8Ud+iOyzPCF+5Qmuh2+qdFFlRTcWOnlFUgfEsPCLSgD0I8kRQs00GttIyMqTGdVD1 EXU/M/jI9zsBNTfNqGG4p5hPBB/nk7lQRc/KdEvVhk+f+fSChvyKReu5tRYgze4Ek6OI rUW57bcyxMiuPOrKXlrdUJWdRaIop+R46XtNn9iev0Z4OMIn2fjYlifA7Cz0zYncLo2B mEggyP7bhFZ1sHKJ+nnIoL7wdqa/Huyai1zeuQrZE3rDfrW4ln70IwScTvBrbYoDJz98 MVBcbSLQX32GoUXre847HKrReYgAA7xpWpp3L1CFppwCHmMP+euiLbZt91QOLg56KqDW Qc4Q== X-Gm-Message-State: AOAM532u+dN5qulE6BCsS2MTMXhVcpwwe6Z+LuAPBsjBMwEU4pQJXhIK HzkZvvQZo2nSut9Ju8PYr7qKp7B0SXNvLhy1TRunNLqERINAW3R1j3A2fE0E7JGwsyvE9YXZlUP n32k= X-Received: by 2002:adf:e40f:: with SMTP id g15mr4048659wrm.600.1641912899518; Tue, 11 Jan 2022 06:54:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5AUeU1ZG1nkF3MrPMBfgmspyhFnqyClA8FGQ+3Exso+lSer6QET8vaK6JOQjt5hxO6R/ScQ== X-Received: by 2002:adf:e40f:: with SMTP id g15mr4048648wrm.600.1641912899350; Tue, 11 Jan 2022 06:54:59 -0800 (PST) Received: from [192.168.0.36] ([78.19.108.41]) by smtp.gmail.com with ESMTPSA id p1sm10203889wrr.75.2022.01.11.06.54.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jan 2022 06:54:59 -0800 (PST) Message-ID: Date: Tue, 11 Jan 2022 14:54:58 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH 2/2] net/nfp: remove useless range checks To: Maxime Gouin , dev@dpdk.org Cc: Heinrich Kuhn , Alejandro Lucero , Olivier Matz References: <20220105103203.7166-1-maxime.gouin@6wind.com> <20220105103203.7166-2-maxime.gouin@6wind.com> From: Kevin Traynor In-Reply-To: <20220105103203.7166-2-maxime.gouin@6wind.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 05/01/2022 10:32, Maxime Gouin wrote: > reported by code analysis tool C++test (version 10.4): > >> /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h >> 375 Condition "island < 1" is always evaluated to false >> 415 Condition "island < 1" is always evaluated to false >> 547 Condition "target < 0" is always evaluated to false > > All of these conditions have the same error. They call > NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and > put the result in "island" or "target" which are integers. These variables > can only contain values between 0 and 255. > > Fixes: c7e9729da6b5 ("net/nfp: support CPP") > Cc: stable@dpdk.org > Signed-off-by: Maxime Gouin > Reviewed-by: Olivier Matz > --- Acked-by: Kevin Traynor > drivers/net/nfp/nfpcore/nfp_target.h | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h > index 2884a0034f44..e8dcc9ad1eda 100644 > --- a/drivers/net/nfp/nfpcore/nfp_target.h > +++ b/drivers/net/nfp/nfpcore/nfp_target.h > @@ -37,7 +37,7 @@ pushpull_width(int pp) > static inline int > target_rw(uint32_t cpp_id, int pp, int start, int len) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > if (island && (island < start || island > (start + len))) > return NFP_ERRNO(EINVAL); > @@ -117,7 +117,7 @@ nfp6000_nbi_ppc(uint32_t cpp_id) > static inline int > nfp6000_nbi(uint32_t cpp_id, uint64_t address) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > uint64_t rel_addr = address & 0x3fFFFF; > > if (island && (island < 8 || island > 9)) > @@ -281,7 +281,7 @@ static inline int > nfp6000_mu(uint32_t cpp_id, uint64_t address) > { > int pp; > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > if (island == 0) { > if (address < 0x2000000000ULL) > @@ -316,7 +316,7 @@ nfp6000_mu(uint32_t cpp_id, uint64_t address) > static inline int > nfp6000_ila(uint32_t cpp_id) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > if (island && (island < 48 || island > 51)) > return NFP_ERRNO(EINVAL); > @@ -336,7 +336,7 @@ nfp6000_ila(uint32_t cpp_id) > static inline int > nfp6000_pci(uint32_t cpp_id) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > if (island && (island < 4 || island > 7)) > return NFP_ERRNO(EINVAL); > @@ -354,7 +354,7 @@ nfp6000_pci(uint32_t cpp_id) > static inline int > nfp6000_crypto(uint32_t cpp_id) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > if (island && (island < 12 || island > 15)) > return NFP_ERRNO(EINVAL); > @@ -370,9 +370,9 @@ nfp6000_crypto(uint32_t cpp_id) > static inline int > nfp6000_cap_xpb(uint32_t cpp_id) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > - if (island && (island < 1 || island > 63)) > + if (island > 63) > return NFP_ERRNO(EINVAL); > > switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { > @@ -410,9 +410,9 @@ nfp6000_cap_xpb(uint32_t cpp_id) > static inline int > nfp6000_cls(uint32_t cpp_id) > { > - int island = NFP_CPP_ID_ISLAND_of(cpp_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); > > - if (island && (island < 1 || island > 63)) > + if (island > 63) > return NFP_ERRNO(EINVAL); > > switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { > @@ -540,11 +540,11 @@ nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address, > const uint32_t *imb_table) > { > int err; > - int island = NFP_CPP_ID_ISLAND_of(cpp_island_id); > - int target = NFP_CPP_ID_TARGET_of(cpp_island_id); > + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id); > + uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id); > uint32_t imb; > > - if (target < 0 || target >= 16) > + if (target >= 16) > return NFP_ERRNO(EINVAL); > > if (island == 0) { >