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 270E2A034D; Thu, 6 Jan 2022 09:41:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9EBBB406B4; Thu, 6 Jan 2022 09:41:35 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mails.dpdk.org (Postfix) with ESMTP id 668BE4014F for ; Wed, 5 Jan 2022 11:27:06 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id p1-20020a1c7401000000b00345c2d068bdso1537881wmc.3 for ; Wed, 05 Jan 2022 02:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4gYMR+n/AXlBmXgBbr5YckOiG/d+f8Q0b6b5qlVi6Vk=; b=a9N8f9cxB46CTbdFZ3CvGXCl3TpNSA8VTZ8EnsJKm9EKiQhh4x/qnM9rKZlLdFU1As D4nxK2nZR039tOtuS2/sFjR7JevA8oZaIlmzTAB0EdlP6YRHbbJWiqKbf8mstGvF6q/A Uumm+vAts0h0P1ll+LHKkbvVhdTnJa6d48WzvWwJdPnwL32Baj5sPmy9p7NX29WaP08v pNRE1hdpNLMVeFlTfwEI6HI1NtjbIHBMLq9KUXjU8NBEDLe9RDK4gjN/QbT597mkU3qX GZAFCjPnQo1+p7P9uFTVAalmoEQGtXHww+HpJB0ItxB/hmPOl3hpj38BA5+k7X5ipvmt P63A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4gYMR+n/AXlBmXgBbr5YckOiG/d+f8Q0b6b5qlVi6Vk=; b=kDp/+YiAUHWGV1FZUeOC4wJGjfY8cd2WD6VW3o5S1Hb73cSUdxchzT+GQHVQMjv/o2 T+DVl25zQ0uBlWGnRoKNfzMyFdcOtuudofwrPuwxNdL3+HR/HchGQnRsU7c1WTCiiwYc KwGpiVkT0lmK1jTRw60q+aDjYVQ31moNCldJCn+FYpXOKc6M6JrgSCYCdKdNKh+4MR2B WF3Q1pNTEfbWDFAiAit84fx+oxy3dQSzeipZYDe/3J8VtN8mLo4ThJTS3XkTko3IPk8L r2Kem7yx3OAnCR+3nQjc/halGZPC9u95WaRE5RRgSwPOQR2ey8VH92dzWqS8b16oCK5e DYAg== X-Gm-Message-State: AOAM533URszjLN90puoLxwU/W6Hvk5hyPD2ScmWj7T6i+tDSN78q/DFU l69MSvwFvMWbn0v8jeHm+jVdaw9/4/AAQxZAIMs= X-Google-Smtp-Source: ABdhPJzqjhouLXtvCzjRdPrGpA0K0vglJjL4ZW7dFNrv8hzRSKmqvdJ6qaOD/N0H1oU8ZQwRZYreTA== X-Received: by 2002:a7b:ce14:: with SMTP id m20mr573842wmc.191.1641378426208; Wed, 05 Jan 2022 02:27:06 -0800 (PST) Received: from dokken.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id n1sm43358898wri.46.2022.01.05.02.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 02:27:05 -0800 (PST) From: Maxime Gouin To: dev@dpdk.org Cc: Maxime Gouin , Rosen Xu , Qi Zhang , Tianfei Zhang , Olivier Matz Subject: [PATCH] bus/ifpga: remove useless check while browsing devices Date: Wed, 5 Jan 2022 11:26:52 +0100 Message-Id: <20220105102652.6400-1-maxime.gouin@6wind.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 06 Jan 2022 09:41:34 +0100 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 reported by code analysis tool C++test (version 10.4): > /build/dpdk-20.11/drivers/bus/ifpga/ifpga_bus.c > 67 Condition "afu_dev" is always evaluated to true > 81 Condition "afu_dev" is always evaluated to true The "for" loop already checks that afu_dev is not NULL. Fixes: 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library") Signed-off-by: Maxime Gouin Reviewed-by: Olivier Matz --- drivers/bus/ifpga/ifpga_bus.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index cbc680928486..c5c8bbd57219 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -64,8 +64,7 @@ ifpga_find_afu_dev(const struct rte_rawdev *rdev, struct rte_afu_device *afu_dev = NULL; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (afu_dev && - afu_dev->rawdev == rdev && + if (afu_dev->rawdev == rdev && !ifpga_afu_id_cmp(&afu_dev->id, afu_id)) return afu_dev; } @@ -78,8 +77,7 @@ rte_ifpga_find_afu_by_name(const char *name) struct rte_afu_device *afu_dev = NULL; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (afu_dev && - !strcmp(afu_dev->device.name, name)) + if (!strcmp(afu_dev->device.name, name)) return afu_dev; } return NULL; -- 2.30.2