X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcompiler%2Fcompiler.h;h=49088ac799e6f0ba9772afde55d8a9fdd421f71d;hb=0191b7a74144ea8193961235f45715e715d4d8eb;hp=242ef84d133ddb65ea378bdfcc6585a7f46d7bd8;hpb=18636637ee013ef828cb04b2b7bb4a4922324475;p=ccan diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h index 242ef84d..49088ac7 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(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 */