public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 3/4] test: Use positive conditional in test_matches()
Date: Thu, 11 Feb 2021 16:40:11 +0200	[thread overview]
Message-ID: <20210211144012.55676-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com>

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 <andriy.shevchenko@linux.intel.com>
---
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))
-- 
2.30.0

  parent reply	other threads:[~2021-02-11 14:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 14:40 [PATCH v2 1/4] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
2021-02-11 14:40 ` [PATCH v2 2/4] test: Allow simple glob pattern in the test name Andy Shevchenko
2021-02-18  4:45   ` Simon Glass
2021-04-29 16:03     ` Simon Glass
2021-02-11 14:40 ` Andy Shevchenko [this message]
2021-02-18  4:45   ` [PATCH v2 3/4] test: Use positive conditional in test_matches() Simon Glass
2021-04-29 16:03     ` Simon Glass
2021-02-11 14:40 ` [PATCH v2 4/4] test: Don't unmount not (yet) mounted system Andy Shevchenko
2021-02-18  4:45   ` Simon Glass
2021-02-18 10:55     ` Andy Shevchenko
2021-02-19  4:52       ` Simon Glass
2021-03-30 19:41         ` Andy Shevchenko
2021-03-30 19:53           ` Tom Rini
2021-03-30 21:50             ` Andy Shevchenko
2021-03-31 13:47   ` Tom Rini
2021-05-13 11:32   ` Heinrich Schuchardt
2021-05-17  6:36     ` Andy Shevchenko
2021-02-11 14:46 ` [PATCH v2 1/4] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
2021-02-18  4:45 ` Simon Glass
2021-03-15 13:59 ` Andy Shevchenko
2021-03-18 16:56 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210211144012.55676-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox