[Piglit] [PATCH 01/13] util: Add func streq()
Chad Versace
chad.versace at linux.intel.com
Wed Mar 26 10:40:17 PDT 2014
Please. Let's stop writing `!strcmp(...)` and `strcmp(...) == 0`. This
patch defines a little function streq() that reads much more nicely than
idioms using strcmp.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
tests/util/piglit-util.c | 6 ++++++
tests/util/piglit-util.h | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 0f3964c..d5a51ed 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -107,6 +107,12 @@ int asprintf(char **strp, const char *fmt, ...)
#endif /* HAVE_ASPRINTF */
+bool
+streq(const char *a, const char *b)
+{
+ return strcmp(a, b) == 0;
+}
+
/**
* \brief Split \a string into an array of strings.
*
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 4882e75..84d4726 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -123,6 +123,12 @@ enum piglit_result {
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
+
+/**
+ * Return true if and only if two string are equal according to strcmp().
+ */
+bool streq(const char *a, const char *b);
+
/**
* Determine if an extension is listed in an extension string
*
--
1.8.5.3
More information about the Piglit
mailing list