This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] nscd: list all tables in usage()


On Wednesday 01 January 2014 07:38:35 Sami Kerola wrote:
> 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.

can you show an example of before & after output ?

> --- a/nscd/nscd.c
> +++ b/nscd/nscd.c
>  more_help (int key, const char *text, void *input)
>  {
> -  char *tp = NULL;
> +  char *tables, *p, *tp = NULL;
>    switch (key)
>      {
>      case ARGP_KEY_HELP_EXTRA:
> +      {
> +	dbtype cnt;
> +	size_t len;
> +	tables = xmalloc (sizeof (dbnames) + 1);

i think GNU style says there should be a newline after the decls

> +	p = tables;
> +	for (cnt = 0; cnt < lastdb; cnt++)
> +	  {
> +	    len = strlen (dbnames[cnt]);
> +	    memcpy (p, dbnames[cnt], len);
> +	    p += len;
> +	    *p++ = ' ';

how about just strcat ?  would be a little slower, but would be simpler code.
	tables = xmalloc (sizeof (dbnames) + 1);
	for (cnt = 0; cnt < lastdb; ++cnt) {
		strcat (tables, dbnames[cnt]);
		strcat (tables, ' ');
	}
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]