[Mesa-dev] [RFC libdrm 3/5] android: Mark alloc_handle_t magic variable as const

Rob Herring robh at kernel.org
Wed Dec 13 20:48:19 UTC 2017


On Wed, Dec 13, 2017 at 11:30 AM, Robert Foss <robert.foss at collabora.com> wrote:
> Mark magic member of alloc_handle_t as const.
> Also bump the version of alloc_handle_t.
>
> Sign-off-by: Robert Foss <robert.foss at collabora.com>
> ---
>  android/alloc_handle.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/android/alloc_handle.h b/android/alloc_handle.h
> index b722615638e7..fe93ad7e6567 100644
> --- a/android/alloc_handle.h
> +++ b/android/alloc_handle.h
> @@ -32,7 +32,7 @@ struct alloc_handle_t {
>         native_handle_t base;
>
>         /* api variables */
> -       int magic; /* differentiate between allocator impls */
> +       const int magic; /* differentiate between allocator impls */
>         const int version; /* api version */
>
>         int prime_fd; /* dma-buf file descriptor */
> @@ -52,7 +52,7 @@ struct alloc_handle_t {
>         } __attribute__((aligned(8)));
>  };
>
> -#define ALLOC_HANDLE_VERSION 1
> +#define ALLOC_HANDLE_VERSION 2

I don't think bumping the version here is necessary. Users can only be
directly accessing the member and no run-time version checking would
fix the compile time breakage. IOW, this isn't a backwards compatible
change, so a version check is not going to help. Plus, it's highly
unlikely any user modifies magic.

Rob


More information about the mesa-dev mailing list