From patchwork Sat Dec 7 15:33:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1205480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47VYQT0KvJz9sPK; Sun, 8 Dec 2019 02:33:51 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1idc5a-0006h5-8R; Sat, 07 Dec 2019 15:33:46 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1idc5Y-0006gp-Df for fwts-devel@lists.ubuntu.com; Sat, 07 Dec 2019 15:33:44 +0000 Received: from [82.43.126.140] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1idc5Y-0006yj-3T; Sat, 07 Dec 2019 15:33:44 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] cpu: microcode: remove redundant check on pointer entry Date: Sat, 7 Dec 2019 15:33:43 +0000 Message-Id: <20191207153343.112887-1-colin.king@canonical.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King The check for a null entry is redundant as the while loop also checks for this. Remove the redundant check. Cleans up cppcheck style warning: src/cpu/microcode/microcode.c:203:14: style: Condition 'entry' is always true [knownConditionTrueFalse] if (entry && src/cpu/microcode/microcode.c:202:32: note: Assuming that condition '(entry=readdir(dir))!=NULL' is not redundant while ((entry = readdir(dir)) != NULL) { src/cpu/microcode/microcode.c:203:14: note: Condition 'entry' is always true if (entry && Signed-off-by: Colin Ian King Acked-by: Alex Hung --- src/cpu/microcode/microcode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c index 974fdec9..65abe50a 100644 --- a/src/cpu/microcode/microcode.c +++ b/src/cpu/microcode/microcode.c @@ -200,8 +200,7 @@ static int microcode_test1(fwts_framework *fw) /* Scan and check */ while ((entry = readdir(dir)) != NULL) { - if (entry && - (strlen(entry->d_name) > 3) && + if ((strlen(entry->d_name) > 3) && (strncmp(entry->d_name,"cpu", 3) == 0) && (isdigit(entry->d_name[3]))) { char path[PATH_MAX];