From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: erik.sjolund@gmail.com, David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 1/3] conf: Remove unhelpful usage() wrapper
Date: Wed, 29 May 2024 19:04:03 +1000 [thread overview]
Message-ID: <20240529090405.965748-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240529090405.965748-1-david@gibson.dropbear.id.au>
usage() does nothing but call print_usage() with EXIT_FAILURE as a
parameter. It's no more complex to just give that parameter at the single
call site. Eliminate it and rename print_usage() to just usage().
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
conf.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/conf.c b/conf.c
index 50383a39..f2a92574 100644
--- a/conf.c
+++ b/conf.c
@@ -704,11 +704,11 @@ static unsigned int conf_ip6(unsigned int ifi,
}
/**
- * print_usage() - Print usage, exit with given status code
+ * usage() - Print usage, exit with given status code
* @name: Executable name
* @status: Status code for exit()
*/
-static void print_usage(const char *name, int status)
+static void usage(const char *name, int status)
{
if (strstr(name, "pasta")) {
info("Usage: %s [OPTION]... [COMMAND] [ARGS]...", name);
@@ -897,15 +897,6 @@ pasta_opts:
exit(status);
}
-/**
- * usage() - Print usage and exit with failure
- * @name: Executable name
- */
-static void usage(const char *name)
-{
- print_usage(name, EXIT_FAILURE);
-}
-
/**
* conf_print() - Print fundamental configuration parameters
* @c: Execution context
@@ -1647,11 +1638,11 @@ void conf(struct ctx *c, int argc, char **argv)
break;
case 'h':
log_to_stdout = 1;
- print_usage(argv[0], EXIT_SUCCESS);
+ usage(argv[0], EXIT_SUCCESS);
break;
case '?':
default:
- usage(argv[0]);
+ usage(argv[0], EXIT_FAILURE);
break;
}
} while (name != -1);
--
@@ -704,11 +704,11 @@ static unsigned int conf_ip6(unsigned int ifi,
}
/**
- * print_usage() - Print usage, exit with given status code
+ * usage() - Print usage, exit with given status code
* @name: Executable name
* @status: Status code for exit()
*/
-static void print_usage(const char *name, int status)
+static void usage(const char *name, int status)
{
if (strstr(name, "pasta")) {
info("Usage: %s [OPTION]... [COMMAND] [ARGS]...", name);
@@ -897,15 +897,6 @@ pasta_opts:
exit(status);
}
-/**
- * usage() - Print usage and exit with failure
- * @name: Executable name
- */
-static void usage(const char *name)
-{
- print_usage(name, EXIT_FAILURE);
-}
-
/**
* conf_print() - Print fundamental configuration parameters
* @c: Execution context
@@ -1647,11 +1638,11 @@ void conf(struct ctx *c, int argc, char **argv)
break;
case 'h':
log_to_stdout = 1;
- print_usage(argv[0], EXIT_SUCCESS);
+ usage(argv[0], EXIT_SUCCESS);
break;
case '?':
default:
- usage(argv[0]);
+ usage(argv[0], EXIT_FAILURE);
break;
}
} while (name != -1);
--
2.45.1
next prev parent reply other threads:[~2024-05-29 9:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 9:04 [PATCH 0/3] conf, log: Fix regression in usage() printing David Gibson
2024-05-29 9:04 ` David Gibson [this message]
2024-05-29 9:04 ` [PATCH 2/3] conf: Don't print usage via the logging subsystem David Gibson
2024-06-04 22:40 ` Stefano Brivio
2024-06-04 23:51 ` David Gibson
2024-05-29 9:04 ` [PATCH 3/3] log: Remove log_to_stdout option David Gibson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240529090405.965748-2-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=erik.sjolund@gmail.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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://passt.top/passt
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 IMAP folder(s).