[RFC PATCH 17/21] usage.c: move usage routines around

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A move-only change to re-order the usage routines in the order of
usage,die,die_message,error,warning, and to have the "errno" variant
after the non-errno variant, in addition to defining them all after
the fmt_with_err() helper which some of them need.

This change make a subsequent non-refactoring commit's diff smaller.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 usage.c | 84 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/usage.c b/usage.c
index b41f8618f34..28005106f10 100644
--- a/usage.c
+++ b/usage.c
@@ -154,34 +154,6 @@ void set_die_is_recursing_routine(int (*routine)(void))
 	die_is_recursing = routine;
 }
 
-void NORETURN usagef(const char *err, ...)
-{
-	va_list params;
-
-	va_start(params, err);
-	usage_routine(err, params);
-	va_end(params);
-}
-
-void NORETURN usage(const char *err)
-{
-	usagef("%s", err);
-}
-
-void NORETURN die(const char *err, ...)
-{
-	va_list params;
-
-	if (die_is_recursing()) {
-		fputs("fatal: recursion detected in die handler\n", stderr);
-		exit(128);
-	}
-
-	va_start(params, err);
-	die_routine(err, params);
-	va_end(params);
-}
-
 static const char *fmt_with_err(char *buf, int n, const char *fmt)
 {
 	char str_error[256], *err;
@@ -206,6 +178,34 @@ static const char *fmt_with_err(char *buf, int n, const char *fmt)
 	return buf;
 }
 
+void NORETURN usage(const char *err)
+{
+	usagef("%s", err);
+}
+
+void NORETURN usagef(const char *err, ...)
+{
+	va_list params;
+
+	va_start(params, err);
+	usage_routine(err, params);
+	va_end(params);
+}
+
+void NORETURN die(const char *err, ...)
+{
+	va_list params;
+
+	if (die_is_recursing()) {
+		fputs("fatal: recursion detected in die handler\n", stderr);
+		exit(128);
+	}
+
+	va_start(params, err);
+	die_routine(err, params);
+	va_end(params);
+}
+
 void NORETURN die_errno(const char *fmt, ...)
 {
 	char buf[1024];
@@ -245,45 +245,45 @@ int die_message_errno(const char *fmt, ...)
 	return -1;
 }
 
-#undef error_errno
-int error_errno(const char *fmt, ...)
+#undef error
+int error(const char *err, ...)
 {
-	char buf[1024];
 	va_list params;
 
-	va_start(params, fmt);
-	error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
+	va_start(params, err);
+	error_routine(err, params);
 	va_end(params);
 	return -1;
 }
 
-#undef error
-int error(const char *err, ...)
+#undef error_errno
+int error_errno(const char *fmt, ...)
 {
+	char buf[1024];
 	va_list params;
 
-	va_start(params, err);
-	error_routine(err, params);
+	va_start(params, fmt);
+	error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
 	va_end(params);
 	return -1;
 }
 
-void warning_errno(const char *warn, ...)
+void warning(const char *warn, ...)
 {
-	char buf[1024];
 	va_list params;
 
 	va_start(params, warn);
-	warning_routine(fmt_with_err(buf, sizeof(buf), warn), params);
+	warning_routine(warn, params);
 	va_end(params);
 }
 
-void warning(const char *warn, ...)
+void warning_errno(const char *warn, ...)
 {
+	char buf[1024];
 	va_list params;
 
 	va_start(params, warn);
-	warning_routine(warn, params);
+	warning_routine(fmt_with_err(buf, sizeof(buf), warn), params);
 	va_end(params);
 }
 
-- 
2.34.0.rc2.809.g11e21d44b24




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux