X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcompiler%2Fcompiler.h;h=7adcc8ca1a4ea521cb11069d3dce4dff062ecb14;hp=242ef84d133ddb65ea378bdfcc6585a7f46d7bd8;hb=d40331c745a6e4a56a3ea210ef9e1e264f7e6e5a;hpb=18636637ee013ef828cb04b2b7bb4a4922324475 diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h index 242ef84d..7adcc8ca 100644 --- a/ccan/compiler/compiler.h +++ b/ccan/compiler/compiler.h @@ -136,4 +136,23 @@ /* If we don't know, assume it's not. */ #define IS_COMPILE_CONSTANT(expr) 0 #endif + +#if HAVE_WARN_UNUSED_RESULT +/** + * WARN_UNUSED_RESULT - warn if a function return value is unused. + * + * Used to mark a function where it is extremely unlikely that the caller + * can ignore the result, eg realloc(). + * + * Example: + * // buf param may be freed by this; need return value! + * static char *WARN_UNUSED_RESULT enlarge(const char *buf, unsigned *size) + * { + * return realloc(buf, (*size) *= 2); + * } + */ +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define WARN_UNUSED_RESULT +#endif #endif /* CCAN_COMPILER_H */