Skip to content

Commit 4df5e91

Browse files
peffgitster
authored andcommitted
error_errno: use constant return similar to error()
Commit e208f9c (make error()'s constant return value more visible, 2012-12-15) introduced some macro trickery to make the constant return from error() more visible to callers, which in turn can help gcc produce better warnings (and possibly even better code). Later, fd1d672 (usage.c: add warning_errno() and error_errno(), 2016-05-08) introduced another variant, and subsequent commits converted some uses of error() to error_errno(), losing the magic from e208f9c for those sites. As a result, compiling vcs-svn/svndiff.c with "gcc -O3" produces -Wmaybe-uninitialized false positives (at least with gcc 6.2.0). Let's give error_errno() the same treatment, which silences these warnings. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e0c1cea commit 4df5e91

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

git-compat-util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ static inline int const_error(void)
436436
return -1;
437437
}
438438
#define error(...) (error(__VA_ARGS__), const_error())
439+
#define error_errno(...) (error_errno(__VA_ARGS__), const_error())
439440
#endif
440441

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

usage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void NORETURN die_errno(const char *fmt, ...)
148148
va_end(params);
149149
}
150150

151+
#undef error_errno
151152
int error_errno(const char *fmt, ...)
152153
{
153154
char buf[1024];

0 commit comments

Comments
 (0)