From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Jeff Hostetler" <jeffhost@microsoft.com>,
"Elijah Newren" <newren@gmail.com>,
"Jonathan Tan" <jonathantanmy@google.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [RFC PATCH 17/21] usage.c: move usage routines around
Date: Mon, 15 Nov 2021 23:18:27 +0100 [thread overview]
Message-ID: <RFC-patch-17.21-c89a580e5ec-20211115T220831Z-avarab@gmail.com> (raw)
In-Reply-To: <RFC-cover-00.21-00000000000-20211115T220831Z-avarab@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2021-11-15 23:18 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 22:18 [RFC PATCH 00/21] C99: show meaningful <file>:<line> in trace2 via macros Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 01/21] git-compat-util.h: clarify GCC v.s. C99-specific in comment Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 02/21] C99 support: hard-depend on C99 variadic macros Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 03/21] usage.c: add a die_message() routine Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 04/21] usage.c API users: use die_message() where appropriate Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 05/21] usage.c + gc: add and use a die_message_errno() Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 06/21] config API: don't use vreportf(), make it static in usage.c Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 07/21] common-main.c: call exit(), don't return Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 08/21] usage.c: add a non-fatal bug() function to go with BUG() Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 09/21] parse-options.[ch] API: use bug() to improve error output Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 10/21] receive-pack: use bug() and BUG_if_bug() Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 11/21] cache-tree.c: " Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 12/21] pack-objects: use BUG(...) not die("BUG: ...") Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 13/21] strbuf.h: " Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 14/21] usage API: create a new usage.h, move API docs there Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 15/21] usage.[ch] API users: use report_fn, not hardcoded prototype Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 16/21] usage.[ch] API: rename "warn" vars functions to "warning" Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` Ævar Arnfjörð Bjarmason [this message]
2021-11-15 22:18 ` [RFC PATCH 18/21] usage.c: move rename variables in usage routines around Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 19/21] usage API: use C99 macros for {usage,usagef,die,error,warning,die}*() Ævar Arnfjörð Bjarmason
2021-12-27 19:32 ` Jeff Hostetler
2021-12-27 23:01 ` Ævar Arnfjörð Bjarmason
2021-12-28 16:32 ` Jeff Hostetler
2021-12-28 18:51 ` Elijah Newren
2021-12-28 23:48 ` Ævar Arnfjörð Bjarmason
2021-12-29 2:15 ` Elijah Newren
2021-12-28 23:42 ` Ævar Arnfjörð Bjarmason
2021-12-29 16:13 ` Jeff Hostetler
2021-11-15 22:18 ` [RFC PATCH 20/21] usage API: make the "{usage,fatal,error,warning,BUG}: " translatable Ævar Arnfjörð Bjarmason
2021-11-15 22:18 ` [RFC PATCH 21/21] usage API: add "core.usageAddSource" config to add <file>:<line> Ævar Arnfjörð Bjarmason
2021-11-16 18:43 ` [RFC PATCH 00/21] C99: show meaningful <file>:<line> in trace2 via macros Taylor Blau
2021-11-16 18:58 ` Ævar Arnfjörð Bjarmason
2021-11-16 19:36 ` Taylor Blau
2021-11-16 20:16 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=RFC-patch-17.21-c89a580e5ec-20211115T220831Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=jonathantanmy@google.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).