diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-02-11 16:40:11 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-04-29 03:23:39 -0700 |
commit | 494a5e126b4de48091a161436839647246b29d29 (patch) | |
tree | b288bb26a3fcd0c6b03456a52408197e79da2c1f | |
parent | ff232a72969567cd0339d4f96fa0b1840bef500e (diff) | |
download | u-boot-494a5e126b4de48091a161436839647246b29d29.zip u-boot-494a5e126b4de48091a161436839647246b29d29.tar.gz u-boot-494a5e126b4de48091a161436839647246b29d29.tar.bz2 |
test: Use positive conditional in test_matches()
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/test-main.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test-main.c b/test/test-main.c index 1824cce..7afe874 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -148,16 +148,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)) |