From: Junio C Hamano Date: Sun, 6 Jan 2013 07:42:00 +0000 (-0800) Subject: Merge branch 'jk/error-const-return' X-Git-Tag: v1.8.2-rc0~179 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/29fb15152584455590905726cb5a0e26ea26e9eb?ds=inline;hp=-c Merge branch 'jk/error-const-return' Help compilers' flow analysis by making it more explicit that error() always returns -1, to reduce false "variable used uninitialized" warnings. Looks somewhat ugly but not too much. * jk/error-const-return: silence some -Wuninitialized false positives make error()'s constant return value more visible --- 29fb15152584455590905726cb5a0e26ea26e9eb diff --combined cache.h index 8ceb6b8e8d,0e8e5d8002..e1df1e40dd --- a/cache.h +++ b/cache.h @@@ -473,8 -473,6 +473,8 @@@ extern int index_name_is_other(const st extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); +#define PATHSPEC_ONESTAR 1 /* the pathspec pattern sastisfies GFNM_ONESTAR */ + struct pathspec { const char **raw; /* get_pathspec() result, not freed by free_pathspec() */ int nr; @@@ -484,8 -482,7 +484,8 @@@ struct pathspec_item { const char *match; int len; - unsigned int use_wildcard:1; + int nowildcard_len; + int flags; } *items; }; @@@ -717,11 -714,10 +717,11 @@@ static inline int is_absolute_path(cons } int is_directory(const char *); const char *real_path(const char *path); +const char *real_path_if_valid(const char *path); const char *absolute_path(const char *path); const char *relative_path(const char *abs, const char *base); int normalize_path_copy(char *dst, const char *src); -int longest_ancestor_length(const char *path, const char *prefix_list); +int longest_ancestor_length(const char *path, struct string_list *prefixes); char *strip_path_suffix(const char *path, const char *suffix); int daemon_avoid_alias(const char *path); int offset_1st_component(const char *path); @@@ -1003,19 -999,14 +1003,19 @@@ struct ref unsigned char old_sha1[20]; unsigned char new_sha1[20]; char *symref; - unsigned int force:1, + unsigned int + force:1, + requires_force:1, merge:1, nonfastforward:1, + not_forwardable:1, + update:1, deletion:1; enum { REF_STATUS_NONE = 0, REF_STATUS_OK, REF_STATUS_REJECT_NONFASTFORWARD, + REF_STATUS_REJECT_ALREADY_EXISTS, REF_STATUS_REJECT_NODELETE, REF_STATUS_UPTODATE, REF_STATUS_REMOTE_REJECT, @@@ -1145,6 -1136,9 +1145,9 @@@ extern int check_repository_format_vers extern int git_env_bool(const char *, int); extern int git_config_system(void); extern int config_error_nonbool(const char *); + #ifdef __GNUC__ + #define config_error_nonbool(s) (config_error_nonbool(s), -1) + #endif extern const char *get_log_output_encoding(void); extern const char *get_commit_output_encoding(void); @@@ -1164,7 -1158,6 +1167,7 @@@ extern int author_ident_sufficiently_gi extern const char *git_commit_encoding; extern const char *git_log_output_encoding; extern const char *git_mailmap_file; +extern const char *git_mailmap_blob; /* IO helper functions */ extern void maybe_flush_or_die(FILE *, const char *); diff --combined config.c index 97364c03fc,526f682374..053970f369 --- a/config.c +++ b/config.c @@@ -839,8 -839,6 +839,8 @@@ static int git_default_mailmap_config(c { if (!strcmp(var, "mailmap.file")) return git_config_string(&git_mailmap_file, var, value); + if (!strcmp(var, "mailmap.blob")) + return git_config_string(&git_mailmap_blob, var, value); /* Add other config variables here and to Documentation/config.txt. */ return 0; @@@ -1662,6 -1660,7 +1662,7 @@@ int git_config_rename_section(const cha * Call this to report error for your variable that should not * get a boolean value (i.e. "[my] var" means "true"). */ + #undef config_error_nonbool int config_error_nonbool(const char *var) { return error("Missing value for '%s'", var); diff --combined git-compat-util.h index 610e6b7ea4,9002bca28e..9661bc9f73 --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -75,7 -75,7 +75,7 @@@ # endif #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \ !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \ - !defined(__TANDEM) + !defined(__TANDEM) && !defined(__QNX__) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif @@@ -99,14 -99,12 +99,14 @@@ #include #include #include -#ifdef __TANDEM /* or HAVE_STRINGS_H or !NO_STRINGS_H? */ +#ifdef HAVE_STRINGS_H #include /* for strcasecmp() */ #endif #include #include +#ifdef NEEDS_SYS_PARAM_H #include +#endif #include #include #include @@@ -290,6 -288,17 +290,17 @@@ extern NORETURN void die_errno(const ch 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 have to restrict this trick to + * gcc, though, because of the variadic macro and the magic ## comma pasting + * behavior. But 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(fmt, ...) (error((fmt), ##__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)); @@@ -413,10 -422,6 +424,10 @@@ void *gitmemmem(const void *haystack, s const void *needle, size_t needlelen); #endif +#ifdef NO_GETPAGESIZE +#define getpagesize() sysconf(_SC_PAGESIZE) +#endif + #ifdef FREAD_READS_DIRECTORIES #ifdef fopen #undef fopen