Mesa (master): mesa: Add a MUST_CHECK macro for __attribute__(( warn_unused_result)).

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Jul 6 20:41:59 UTC 2015


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Jul  6 11:04:19 2015 -0700

mesa: Add a MUST_CHECK macro for __attribute__((warn_unused_result)).

In the kernel, this is called __must_check; all our attribute macros in
Mesa appear to be uppercase, so I went with that.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 configure.ac      |    1 +
 src/util/macros.h |    6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index ea0f069..d240c06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,6 +210,7 @@ AX_GCC_FUNC_ATTRIBUTE([format])
 AX_GCC_FUNC_ATTRIBUTE([malloc])
 AX_GCC_FUNC_ATTRIBUTE([packed])
 AX_GCC_FUNC_ATTRIBUTE([unused])
+AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
 
 AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
 
diff --git a/src/util/macros.h b/src/util/macros.h
index 3b708ed..66698e7 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -182,6 +182,12 @@ do {                       \
 #define UNUSED
 #endif
 
+#ifdef HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT
+#define MUST_CHECK __attribute__((warn_unused_result))
+#else
+#define MUST_CHECK
+#endif
+
 /** Compute ceiling of integer quotient of A divided by B. */
 #define DIV_ROUND_UP( A, B )  ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
 




More information about the mesa-commit mailing list