usage.c: add warning_errno() and error_errno()

Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2016-05-08 16:47:22 +07:00
committed by Junio C Hamano
parent 58e4e5118a
commit fd1d672300
2 changed files with 23 additions and 0 deletions

21
usage.c
View File

@ -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, ...)
{
@ -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;