Skip to content

Commit 610a14f

Browse files
committed
Merge branch 'jk/squelch-compiler-warning-from-funny-error-macro'
* jk/squelch-compiler-warning-from-funny-error-macro: let clang use the constant-return error() macro inline constant return from error() function
2 parents d2a274a + ff0a80a commit 610a14f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,8 @@ extern int check_repository_format_version(const char *var, const char *value, v
12941294
extern int git_env_bool(const char *, int);
12951295
extern int git_config_system(void);
12961296
extern int config_error_nonbool(const char *);
1297-
#if defined(__GNUC__) && ! defined(__clang__)
1298-
#define config_error_nonbool(s) (config_error_nonbool(s), -1)
1297+
#if defined(__GNUC__)
1298+
#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
12991299
#endif
13001300
extern const char *get_log_output_encoding(void);
13011301
extern const char *get_commit_output_encoding(void);

git-compat-util.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,12 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
330330
* trying to help gcc, anyway, it's OK; other compilers will fall back to
331331
* using the function as usual.
332332
*/
333-
#if defined(__GNUC__) && ! defined(__clang__)
334-
#define error(...) (error(__VA_ARGS__), -1)
333+
#if defined(__GNUC__)
334+
static inline int const_error(void)
335+
{
336+
return -1;
337+
}
338+
#define error(...) (error(__VA_ARGS__), const_error())
335339
#endif
336340

337341
extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));

parse-options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ extern NORETURN void usage_msg_opt(const char *msg,
176176

177177
extern int optbug(const struct option *opt, const char *reason);
178178
extern int opterror(const struct option *opt, const char *reason, int flags);
179-
#if defined(__GNUC__) && ! defined(__clang__)
180-
#define opterror(o,r,f) (opterror((o),(r),(f)), -1)
179+
#if defined(__GNUC__)
180+
#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
181181
#endif
182182

183183
/*----- incremental advanced APIs -----*/

0 commit comments

Comments
 (0)