mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-12-08 08:23:47 +03:00
Import code annotation macros from libvirt
Import ATTRIBUTE_RETURN_CHECK, ATTRIBUTE_UNUSED & ATTRIBUTE_NONNULL macros Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
@@ -54,4 +54,56 @@
|
|||||||
# define ignore_value(x) ((void) (x))
|
# define ignore_value(x) ((void) (x))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef __GNUC__
|
||||||
|
/**
|
||||||
|
* ATTRIBUTE_UNUSED:
|
||||||
|
*
|
||||||
|
* Macro to flag consciously unused parameters to functions
|
||||||
|
*/
|
||||||
|
# ifndef ATTRIBUTE_UNUSED
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* gcc's handling of attribute nonnull is less than stellar - it does
|
||||||
|
* NOT improve diagnostics, and merely allows gcc to optimize away
|
||||||
|
* null code checks even when the caller manages to pass null in spite
|
||||||
|
* of the attribute, leading to weird crashes. Coverity, on the other
|
||||||
|
* hand, knows how to do better static analysis based on knowing
|
||||||
|
* whether a parameter is nonnull. Make this attribute conditional
|
||||||
|
* based on whether we are compiling for real or for analysis, while
|
||||||
|
* still requiring correct gcc syntax when it is turned off. See also
|
||||||
|
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308 */
|
||||||
|
# ifndef ATTRIBUTE_NONNULL
|
||||||
|
# if __GNUC_PREREQ (3, 3)
|
||||||
|
# if STATIC_ANALYSIS
|
||||||
|
# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m)))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_NONNULL(m) __attribute__(())
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_NONNULL(m)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ATTRIBUTE_RETURN_CHECK
|
||||||
|
# if __GNUC_PREREQ (3, 4)
|
||||||
|
# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_RETURN_CHECK
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# else
|
||||||
|
# ifndef ATTRIBUTE_UNUSED
|
||||||
|
# define ATTRIBUTE_UNUSED
|
||||||
|
# endif
|
||||||
|
# ifndef ATTRIBUTE_NONNULL
|
||||||
|
# define ATTRIBUTE_NONNULL(m)
|
||||||
|
# endif
|
||||||
|
# ifndef ATTRIBUTE_RETURN_CHECK
|
||||||
|
# define ATTRIBUTE_RETURN_CHECK
|
||||||
|
# endif
|
||||||
|
# endif /* __GNUC__ */
|
||||||
|
|
||||||
|
|
||||||
#endif /* __LIBVIRT_UTILS_H__ */
|
#endif /* __LIBVIRT_UTILS_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user