opt: Fix -Wmissing-field-initializers warning
[ccan] / ccan / opt / usage.c
index b7381bc7378c6673c742d6dc23b0c42f211e8265..60e1586861adc0981a5bf0eaf00bc63bcff450a4 100644 (file)
@@ -28,6 +28,17 @@ char *opt_usage(const char *argv0, const char *extra)
        unsigned int i, num, len;
        char *ret, *p;
 
+       if (!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;
+                               break;
+                       }
+               }
+       }
+
        /* An overestimate of our length. */
        len = strlen("Usage: %s ") + strlen(argv0)
                + strlen("[-%.*s]") + opt_num_short + 1
@@ -82,7 +93,7 @@ char *opt_usage(const char *argv0, const char *extra)
                        len += sprintf(p + len, " <arg>");
                len += sprintf(p + len, "%.*s",
                               len < strlen(OPT_SPACE_PAD)
-                              ? strlen(OPT_SPACE_PAD) - len : 1,
+                              ? (unsigned)strlen(OPT_SPACE_PAD) - len : 1,
                               OPT_SPACE_PAD);
 
                len += sprintf(p + len, "%s", opt_table[i].desc);