diff options
author | Gregory Maxwell <greg@xiph.org> | 2012-06-01 02:21:53 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-06-01 15:58:17 -0400 |
commit | c64f4a4265c66e5bcc7fbd621641aeb3a3280fdc (patch) | |
tree | 54068a619a4d2c2bc0d32009aa60f15e1bdbd20e /include/opus_defines.h | |
parent | bcbf40b601683be9512c171c069935c1f26c98db (diff) | |
download | opus-c64f4a4265c66e5bcc7fbd621641aeb3a3280fdc.tar.gz |
Update headers to cause warnings on unused returns and null args.
In places where an ignored return or a null-arg is a sure indication
of a bug add the GCC warning attributes. The null arg annotation
is not enable for Opus itself because it will cause the compiler
to optimize out some null checks. I don't trust our callers
quite that much.
Diffstat (limited to 'include/opus_defines.h')
-rw-r--r-- | include/opus_defines.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/opus_defines.h b/include/opus_defines.h index d984f997..54d198be 100644 --- a/include/opus_defines.h +++ b/include/opus_defines.h @@ -75,6 +75,29 @@ extern "C" { # define OPUS_EXPORT #endif +# if !defined(OPUS_GNUC_PREREQ) +# if defined(__GNUC__)&&defined(__GNUC_MINOR__) +# define OPUS_GNUC_PREREQ(_maj,_min) \ + ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) +# else +# define OPUS_GNUC_PREREQ(_maj,_min) 0 +# endif +# endif + +/**Warning attributes for opus functions + * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out + * some paranoid null checks. */ +#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) +# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) +#else +# define OPUS_WARN_UNUSED_RESULT +#endif +#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) +# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) +#else +# define OPUS_ARG_NONNULL(_x) +#endif + /** These are the actual Encoder CTL ID numbers. * They should not be used directly by applications. */ #define OPUS_SET_APPLICATION_REQUEST 4000 |