X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=git-compat-util.h;h=89fdf0561b2e4d427728af36d6ee81a27a187af0;hb=9798f7e5f948b2586c33d850f6a00d4fc0537d75;hp=2e79b8a2f379d7c72a0934b36c7538db2143c722;hpb=05849c4818342a0e0ecb597fd2452125b00d543e;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 2e79b8a2f..89fdf0561 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -288,6 +288,17 @@ extern NORETURN void die_errno(const char *err, ...) __attribute__((format (prin extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); +/* + * Let callers be aware of the constant return value; this can help + * gcc with -Wuninitialized analysis. We restrict this trick to gcc, though, + * because some compilers may not support variadic macros. Since we're only + * trying to help gcc, anyway, it's OK; other compilers will fall back to + * using the function as usual. + */ +#ifdef __GNUC__ +#define error(...) (error(__VA_ARGS__), -1) +#endif + extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params)); extern void set_error_routine(void (*routine)(const char *err, va_list params));