[Mesa-dev] [PATCH 1/7] util: add MAYBE_UNUSED for config dependent variables

Emil Velikov emil.l.velikov at gmail.com
Sat Apr 16 23:50:09 UTC 2016


On 16 April 2016 at 02:00, Grazvydas Ignotas <notasas at gmail.com> wrote:
> This is mostly for variables that are only used in asserts and cause
> unused-but-set-variable warnings in release builds. Could just use
> UNUSED directly, but MAYBE_UNUSED should be less confusing and is
> similar to what the Linux kernel has.
>
> And yes __attribute__((unused)) can be used on variables on both GCC 4.2
> (oldest supported by mesa) and clang 3.0 (just some random old version,
> nut sure what's the minimum for mesa).
>
> Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
> ---
> I have no commit access, if this patch is ok, please someone push.
>
>  src/util/macros.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/util/macros.h b/src/util/macros.h
> index 0c8958f..f081bb8 100644
> --- a/src/util/macros.h
> +++ b/src/util/macros.h
> @@ -204,6 +204,8 @@ do {                       \
>  #define UNUSED
>  #endif
>
> +#define MAYBE_UNUSED UNUSED
> +
Hell yeah !

A thing that comes to mind ... a while back we've been wondering about
(re)naming these just the the way we do in the kernel. Namely
__maybe_unused in this case. Can you give that one a try and link a
branch. I'll push it through Travis-CI to check if the Windows (scons)
build will be ok with the new name.

Thank for going through these.
Emil


More information about the mesa-dev mailing list