X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fopt%2Fusage.c;h=873ee5db1856cf0bf326a8ed4ba9f19aa22c2db6;hb=03f017e9aff901d5d80bd577732543961a13c497;hp=60e1586861adc0981a5bf0eaf00bc63bcff450a4;hpb=5a02610cb444952a1c0fa820f579a4e535f617ec;p=ccan diff --git a/ccan/opt/usage.c b/ccan/opt/usage.c index 60e15868..873ee5db 100644 --- a/ccan/opt/usage.c +++ b/ccan/opt/usage.c @@ -1,3 +1,4 @@ +/* Licensed under GPLv3+ - see LICENSE file for details */ #include #include #include @@ -32,8 +33,8 @@ char *opt_usage(const char *argv0, const char *extra) extra = ""; for (i = 0; i < opt_count; i++) { if (opt_table[i].cb == (void *)opt_usage_and_exit - && opt_table[i].arg) { - extra = opt_table[i].arg; + && opt_table[i].u.carg) { + extra = opt_table[i].u.carg; break; } } @@ -62,9 +63,6 @@ char *opt_usage(const char *argv0, const char *extra) } p = ret = malloc(len); - if (!ret) - return NULL; - p += sprintf(p, "Usage: %s", argv0); p += sprintf(p, " [-"); num = write_short_options(p); @@ -100,7 +98,7 @@ char *opt_usage(const char *argv0, const char *extra) if (opt_table[i].show) { char buf[OPT_SHOW_LEN + sizeof("...")]; strcpy(buf + OPT_SHOW_LEN, "..."); - opt_table[i].show(buf, opt_table[i].arg); + opt_table[i].show(buf, opt_table[i].u.arg); len += sprintf(p + len, " (default: %s)", buf); } p += len;