Skip to content

Commit ff0a80a

Browse files
peffgitster
authored andcommitted
let clang use the constant-return error() macro
Commit e208f9c converted error() into a macro to make its constant return value more apparent to calling code. Commit 5ded807 prevents us using this macro with clang, since clang's -Wunused-value is smart enough to realize that the constant "-1" is useless in some contexts. However, since the last commit puts the constant behind an inline function call, this is enough to prevent the -Wunused-value warning on both modern gcc and clang. So we can now re-enable the macro when compiling with clang. Tested with clang 3.3, 3.4, and 3.5. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87fe5df commit ff0a80a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ extern int check_repository_format_version(const char *var, const char *value, v
11831183
extern int git_env_bool(const char *, int);
11841184
extern int git_config_system(void);
11851185
extern int config_error_nonbool(const char *);
1186-
#if defined(__GNUC__) && ! defined(__clang__)
1186+
#if defined(__GNUC__)
11871187
#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
11881188
#endif
11891189
extern const char *get_log_output_encoding(void);

git-compat-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
342342
* trying to help gcc, anyway, it's OK; other compilers will fall back to
343343
* using the function as usual.
344344
*/
345-
#if defined(__GNUC__) && ! defined(__clang__)
345+
#if defined(__GNUC__)
346346
static inline int const_error(void)
347347
{
348348
return -1;

parse-options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
179179

180180
extern int optbug(const struct option *opt, const char *reason);
181181
extern int opterror(const struct option *opt, const char *reason, int flags);
182-
#if defined(__GNUC__) && ! defined(__clang__)
182+
#if defined(__GNUC__)
183183
#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
184184
#endif
185185

0 commit comments

Comments
 (0)