X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=git-compat-util.h;h=89fdf0561b2e4d427728af36d6ee81a27a187af0;hb=9798f7e5f948b2586c33d850f6a00d4fc0537d75;hp=2fbf1fd8b14a57e065674ffec238406f09b71639;hpb=0d2605112e25bb614d65771a04356639ab370dc3;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 2fbf1fd8b..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)); @@ -506,6 +517,7 @@ extern const char tolower_trans_tbl[256]; #undef isdigit #undef isalpha #undef isalnum +#undef isprint #undef islower #undef isupper #undef tolower @@ -523,6 +535,7 @@ extern unsigned char sane_ctype[256]; #define isdigit(x) sane_istest(x,GIT_DIGIT) #define isalpha(x) sane_istest(x,GIT_ALPHA) #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) +#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e) #define islower(x) sane_iscase(x, 1) #define isupper(x) sane_iscase(x, 0) #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)