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

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 git-compat-util.h |  2 ++
 usage.c           | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index 1f8b5f3..49d4029 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -409,7 +409,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
diff --git a/usage.c b/usage.c
index 8675d72..1dad03f 100644
--- a/usage.c
+++ b/usage.c
@@ -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;
-- 
2.8.0.rc0.210.gd302cd2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to