Mesa (master): util: add MAYBE_UNUSED for config dependent variables

Ian Romanick idr at kemper.freedesktop.org
Mon Apr 25 10:24:06 UTC 2016


Module: Mesa
Branch: master
Commit: e4fc06a2f8be2de3a08d4adfa4a26df2ae0b5cae
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4fc06a2f8be2de3a08d4adfa4a26df2ae0b5cae

Author: Grazvydas Ignotas <notasas at gmail.com>
Date:   Sat Apr 16 04:00:10 2016 +0300

util: add MAYBE_UNUSED for config dependent variables

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,
not sure what's the minimum for mesa).

Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Reviewed-by: Chad Versace <chad.versace at intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

---

 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
+
 #ifdef HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT
 #define MUST_CHECK __attribute__((warn_unused_result))
 #else




More information about the mesa-commit mailing list