Skip to content

Commit

Permalink
usage.c: add warning_errno() and error_errno()
Browse files Browse the repository at this point in the history
Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pclouds authored and gitster committed May 9, 2016
1 parent 58e4e51 commit fd1d672
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,
extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));

#ifndef NO_OPENSSL
#ifdef APPLE_COMMON_CRYPTO
Expand Down
21 changes: 21 additions & 0 deletions usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)
va_end(params);
}

int error_errno(const char *fmt, ...)
{
char buf[1024];
va_list params;

va_start(params, fmt);
error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
va_end(params);
return -1;
}

#undef error
int error(const char *err, ...)
{
Expand All @@ -159,6 +170,16 @@ int error(const char *err, ...)
return -1;
}

void warning_errno(const char *warn, ...)
{
char buf[1024];
va_list params;

va_start(params, warn);
warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
va_end(params);
}

void warning(const char *warn, ...)
{
va_list params;
Expand Down

0 comments on commit fd1d672

Please sign in to comment.