[PATCH] nscd: list all tables in usage()
Sami Kerola
kerolasa@iki.fi
Thu Jan 2 20:49:00 GMT 2014
On 2 January 2014 11:12, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 01 January 2014 15:20:07 Sami Kerola wrote:
>> + char *tables, *tp = NULL;
>> switch (key)
>
> while you're here, could you add a newline above the switch
> statement too ?
Hi Mike, and others,
That and few other empty lines are added. If I'm not wrong the out
come is a bit more align with rest of the code.
>> + tables = xcalloc (1, sizeof (dbnames) + 1);
>
> you could keep the malloc ... just manually set the first byte to
> '\0'. either is OK though.
I should have read the manual page. The strcat() does append '\0'
so your proposal is better than calloc() or any of it's wrappers.
>> + for (cnt = 0; cnt < lastdb; cnt++)
>> + {
>> + strcat (tables, dbnames[cnt]);
>> + strcat (tables, " ");
>> + }
>> + }
>
> hmm, is indentation correct with that first strcat ? seems like
> it should be a tab and then four spaces.
It wasn't, but should be now.
> how about:
> Supported tables:\n%s\n
>
> that seems to match the style we have in `getent --help`.
That might be better wording indeed.
--->8----
From: Sami Kerola <kerolasa@iki.fi>
Date: Wed, 1 Jan 2014 20:17:20 +0000
Subject: [PATCH] nscd: list all tables in usage()
Usage output for option --invalidate=TABLE is not helpful without
list of tables. The list is also missing from nscd(8) manual which
made it pretty difficult to know what are the tables.
---
ChangeLog | 4 ++++
nscd/nscd.c | 24 +++++++++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c2c47d8..a9c7ddb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-01-01 Sami Kerola <kerolasa@iki.fi>
+
+ * nscd/nscd.c: Improve usage() output.
+
2014-01-01 Allan McRae <allan@archlinux.org>
* scripts/update-copyrights: Update configure input file suffix.
diff --git a/nscd/nscd.c b/nscd/nscd.c
index e7f04f8..78e537e 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -442,19 +442,37 @@ parse_opt (int key, char *arg, struct argp_state *state)
static char *
more_help (int key, const char *text, void *input)
{
- char *tp = NULL;
+ char *tables, *tp = NULL;
+
switch (key)
{
case ARGP_KEY_HELP_EXTRA:
+ {
+ dbtype cnt;
+
+ tables = xmalloc (1, sizeof (dbnames) + 1);
+ *tables = '\0';
+ for (cnt = 0; cnt < lastdb; cnt++)
+ {
+ strcat (tables, dbnames[cnt]);
+ strcat (tables, " ");
+ }
+ }
+
/* We print some extra information. */
if (asprintf (&tp, gettext ("\
+Supported tables:\n%s\n\
+\n\
For bug reporting instructions, please see:\n\
-%s.\n"), REPORT_BUGS_TO) < 0)
- return NULL;
+%s.\n"), tables, REPORT_BUGS_TO) < 0)
+ tp = NULL;
+ free (tables);
return tp;
+
default:
break;
}
+
return (char *) text;
}
--
1.8.5.2
More information about the Libc-help
mailing list