[PATCH 3/4] tests: Move ARRAY_LENGTH to a shared header for reuse

Marek Chalupa mchqwerty at gmail.com
Fri Nov 28 03:41:21 PST 2014


IMO it'd be good to add guards (#ifndef ARRAY_LENGTH) around this macro,
because it is used extensively in wayland/weston and in the future it may
happen that
it'll be redefined by some included header.

Reviewed-by: Marek Chalupa <mchqwerty at gmail.com>

On 20 November 2014 at 02:18, Bryce Harrington <bryce at osg.samsung.com>
wrote:

> Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> ---
>  tests/presentation-test.c  | 2 --
>  tests/weston-test-runner.h | 4 +++-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tests/presentation-test.c b/tests/presentation-test.c
> index b99e93d..f97e5b3 100644
> --- a/tests/presentation-test.c
> +++ b/tests/presentation-test.c
> @@ -31,8 +31,6 @@
>  #include "weston-test-client-helper.h"
>  #include "presentation_timing-client-protocol.h"
>
> -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
> -
>  static inline void *
>  xzalloc(size_t size)
>  {
> diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h
> index e1db040..193b76d 100644
> --- a/tests/weston-test-runner.h
> +++ b/tests/weston-test-runner.h
> @@ -41,6 +41,8 @@ struct weston_test {
>         int must_fail;
>  } __attribute__ ((aligned (32)));
>
> +#define ARRAY_LENGTH(a) ((int) (sizeof (a) / sizeof (a)[0]))
> +
>  #define TEST_BEGIN(name, arg)                                  \
>         static void name(arg)
>
> @@ -67,7 +69,7 @@ struct weston_test {
>  #define ARG_TEST(name, ret, test_data)                         \
>         TEST_COMMON(name, name, ret, test_data,                 \
>                     sizeof(test_data[0]),                       \
> -                   sizeof(test_data) / sizeof (test_data[0]))  \
> +                   ARRAY_LENGTH(test_data))                    \
>         TEST_BEGIN(name, void *data)                            \
>
>  #define TEST(name) NO_ARG_TEST(name, 0)
> --
> 1.9.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20141128/88178df1/attachment.html>


More information about the wayland-devel mailing list