alloc() never returns Null
Mark alloc()--also dupstr() and re_alloc()--for gcc and clang as always returning non-Null. This should silence some of the static analysis complaints. Almost all the monster and object naming functions (anything that returns an mbuf or an obuf) should be marked this way too but I'll leave that for somebody else to deal with. I didn't attempt to mark alloc() with the 'malloc' attribute because macro definitions could end up causing trouble. Specifying its deallocator would probably be useful but is at even bigger risk of macro interference. I'm not sure whether gcc 3 is really the right test for whether the returns_nonnull attribute setting is available.
This commit is contained in:
@@ -404,6 +404,7 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#if __GNUC__ >= 3
|
||||
#define UNUSED __attribute__((unused))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NONNULL __attribute__((returns_nonnull))
|
||||
#if !defined(__linux__) || defined(GCC_URWARN)
|
||||
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
|
||||
discarding the result by casting to (void) is not accepted as a 'use' */
|
||||
@@ -422,5 +423,8 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#ifndef NORETURN
|
||||
#define NORETURN
|
||||
#endif
|
||||
#ifndef NONNULL
|
||||
#define NONNULL
|
||||
#endif
|
||||
|
||||
#endif /* TRADSTDC_H */
|
||||
|
||||
Reference in New Issue
Block a user