From 050580d4204d2e9056e68e3ce17787709b956514 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 6 Sep 2008 11:28:38 +0300 Subject: [PATCH] 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. --- include/vlc_common.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/vlc_common.h b/include/vlc_common.h index 65158d0412..d30e82a08e 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -55,6 +55,15 @@ # include #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) -- 2.39.5