[PATCH weston] compositor/clients: Protect CLOCK_BOOTTIME with ifdefs

Giulio Camuffo giuliocamuffo at gmail.com
Sun Oct 4 06:23:38 PDT 2015


2015-06-29 21:20 GMT+03:00 Derek Foreman <derekf at osg.samsung.com>:
> CLOCK_BOOTTIME is a relatively new* feature that may not actually be
> present everywhere (I'm looking at you wheezy).  Since our use of it
> is actually only cosmetic, I've just ifdef'd if.
>
> * No it isn't.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>
> Theoretically, this could bite us if a new clock type is added and it's
> present but CLOCK_BOOTTIME isn't on a system somewhere.  At that point
> we'll probably have to consider moving from a sparse array to something
> more robust...

This can also happen if CLOCK_BOOTTIME is there, if the new clock is >
CLOCK_BOOTTIME+1, so it's not a problem introduced with this patch.

Reviewed-by: Giulio Camuffo <giuliocamuffo at gmail.com>

>
>  clients/weston-info.c | 2 ++
>  src/compositor.c      | 2 ++
>  2 files changed, 4 insertions(+)
>
> diff --git a/clients/weston-info.c b/clients/weston-info.c
> index 89ef8f1..f22781c 100644
> --- a/clients/weston-info.c
> +++ b/clients/weston-info.c
> @@ -579,7 +579,9 @@ clock_name(clockid_t clk_id)
>                 [CLOCK_MONOTONIC_RAW] =         "CLOCK_MONOTONIC_RAW",
>                 [CLOCK_REALTIME_COARSE] =       "CLOCK_REALTIME_COARSE",
>                 [CLOCK_MONOTONIC_COARSE] =      "CLOCK_MONOTONIC_COARSE",
> +#ifdef CLOCK_BOOTTIME
>                 [CLOCK_BOOTTIME] =              "CLOCK_BOOTTIME",
> +#endif
>         };
>
>         if (clk_id < 0 || (unsigned)clk_id >= ARRAY_LENGTH(names))
> diff --git a/src/compositor.c b/src/compositor.c
> index 1e09163..6156ea1 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4760,7 +4760,9 @@ clock_name(clockid_t clk_id)
>                 [CLOCK_MONOTONIC_RAW] =         "CLOCK_MONOTONIC_RAW",
>                 [CLOCK_REALTIME_COARSE] =       "CLOCK_REALTIME_COARSE",
>                 [CLOCK_MONOTONIC_COARSE] =      "CLOCK_MONOTONIC_COARSE",
> +#ifdef CLOCK_BOOTTIME
>                 [CLOCK_BOOTTIME] =              "CLOCK_BOOTTIME",
> +#endif
>         };
>
>         if (clk_id < 0 || (unsigned)clk_id >= ARRAY_LENGTH(names))
> --
> 2.1.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list