[Piglit] [PATCH 01/13] util: Add func streq()
Matt Turner
mattst88 at gmail.com
Wed Mar 26 11:06:01 PDT 2014
On Wed, Mar 26, 2014 at 10:40 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> 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);
It's a one line wrapper -- just define it in the header and let
inlining do its thing.
More information about the Piglit
mailing list