[vlc-devel] commit: LIBVLC_USED: tag for function whose result must be used ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Sep 6 10:27:48 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Sep  6 11:28:38 2008 +0300| [050580d4204d2e9056e68e3ce17787709b956514] | committer: Rémi Denis-Courmont 

LIBVLC_USED: tag for function whose result must be used

GCC will print a warning if the result of such function is ignored
This is useful for functions returning an allocated object (which
would leak if ignored), "getter" functions, and functions that are
"likely" to fail.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=050580d4204d2e9056e68e3ce17787709b956514
---

 include/vlc_common.h |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 65158d0..d30e82a 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -55,6 +55,15 @@
 # include <stdbool.h>
 #endif
 
+/* Format string sanity checks */
+#ifdef __GNUC__
+#   define LIBVLC_FORMAT(x,y) __attribute__ ((format(printf,x,y)))
+#   define LIBVLC_USED __attribute__ ((warn_unused_result))
+#else
+#   define LIBVLC_FORMAT(x,y)
+#   define LIBVLC_USED
+#endif
+
 /*****************************************************************************
  * Basic types definitions
  *****************************************************************************/
@@ -740,13 +749,6 @@ static inline uint64_t ntoh64 (uint64_t ll)
 }
 #define hton64(i) ntoh64(i)
 
-/* Format string sanity checks */
-#ifdef __GNUC__
-#   define LIBVLC_FORMAT(x,y) __attribute__ ((format(printf,x,y)))
-#else
-#   define LIBVLC_FORMAT(x,y)
-#endif
-
 /* */
 #define VLC_UNUSED(x) (void)(x)
 




More information about the vlc-devel mailing list