From patchwork Thu Feb 11 14:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439540 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dbznw6Vfqz9s1l for ; Fri, 12 Feb 2021 01:40:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 785538269C; Thu, 11 Feb 2021 15:40:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id E59C082673; Thu, 11 Feb 2021 15:40:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE87E82656 for ; Thu, 11 Feb 2021 15:40:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: 0VQhb+KMFXaW/N+wJyAU31BxP0uxNOyQm2dkDy0tVjUjm+r/gghJrged2dar79mZ2Kp4bdgruJ cPF7Y99pWcsw== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="161391069" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="161391069" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 06:40:17 -0800 IronPort-SDR: RLLYsdzxgJGYWuwhBT29ZPqzNXdKf3G+NkO9fImSr4akpvgtL6GZPOG+MrCOJKar1nho9EQzHl QvXIyXpS4BxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="422282558" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 11 Feb 2021 06:40:14 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AC50A1FA; Thu, 11 Feb 2021 16:40:13 +0200 (EET) From: Andy Shevchenko To: Simon Glass , u-boot@lists.denx.de, trini@konsulko.com Cc: Andy Shevchenko Subject: [PATCH v2 3/4] test: Use positive conditional in test_matches() Date: Thu, 11 Feb 2021 16:40:11 +0200 Message-Id: <20210211144012.55676-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> References: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean It is easier to read the positive conditional. While at it, convert hard coded length of "_test_" to strlen("_test_") which will be converted to a constant bu optimizing compiler. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v2: new patch test/test-main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-main.c b/test/test-main.c index 8fcbc2361214..344122074e12 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -141,16 +141,16 @@ static bool test_matches(const char *prefix, const char *test_name, if (!strncmp(test_name, select_name, len)) return true; - if (!prefix) { + if (prefix) { + /* All tests have this prefix */ + if (!strncmp(test_name, prefix, strlen(prefix))) + test_name += strlen(prefix); + } else { const char *p = strstr(test_name, "_test_"); /* convert xxx_test_yyy to yyy, i.e. remove the suite name */ if (p) - test_name = p + 6; - } else { - /* All tests have this prefix */ - if (!strncmp(test_name, prefix, strlen(prefix))) - test_name += strlen(prefix); + test_name = p + strlen("_test_"); } if (!strncmp(test_name, select_name, len))