mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 21:47:45 +00:00
stds.h: introduce AFS_NONNULL
AFS_NONNULL wraps the GCC/Clang function attribute __nonnull__, which tells the compiler and the static analyzer that the pointer arguments to a function (or specific ones, if provided) cannot be null. Note that GCC has only limited support for warning about violations of these constraints. Usage examples: int myfunc(struct foo *a, bar_t, struct baz *c) AFS_NONNULL((1)); tells the compiler that the first argument cannot be null (but the third one can). int myfunc2(struct foo *a, bar_t, struct baz *c) AFS_NONNULL(); tells the compiler that both pointer arguments cannot be null. Change-Id: Id81f0c382a6a3bdd9bf9c716eb4091b433129d69 Suggested-by: Simon Wilkinson, comment on change Ic8751737 (#5180) Reviewed-on: http://gerrit.openafs.org/5182 Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
2cd9d0536b
commit
342be35354
@ -296,14 +296,17 @@ hdr_static_inline(unsigned long) afs_printable_uint32_lu(afs_uint32 d) { return
|
||||
#define AFS_UNUSED __attribute__((unused))
|
||||
#define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
|
||||
#define AFS_NORETURN __attribute__((__noreturn__))
|
||||
#define AFS_NONNULL(x) __attribute__((__nonnull x))
|
||||
#elif defined (__clang__)
|
||||
#define AFS_UNUSED __attribute__((unused))
|
||||
#define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
|
||||
#define AFS_NORETURN __attribute__((__noreturn__))
|
||||
#define AFS_NONNULL(x) __attribute__((__nonnull x))
|
||||
#else
|
||||
#define AFS_UNUSED
|
||||
#define AFS_ATTRIBUTE_FORMAT(style,x,y)
|
||||
#define AFS_NORETURN
|
||||
#define AFS_NONNULL(x)
|
||||
#endif
|
||||
|
||||
#endif /* OPENAFS_CONFIG_AFS_STDS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user