diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 673d90cd1619..972e2ffaaf53 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -90,16 +90,16 @@ struct g_command PUBSYM(class_commands)[] = { { 'b', "start", GPART_AUTOFILL, G_TYPE_STRING }, { 's', "size", GPART_AUTOFILL, G_TYPE_STRING }, { 't', "type", NULL, G_TYPE_STRING }, - { 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM }, - { 'l', "label", "", G_TYPE_STRING }, + { 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_ASCNUM }, + { 'l', "label", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "[-b start] [-s size] -t type [-i index] [-l label] [-f flags] geom" }, { "bootcode", 0, gpart_bootcode, { - { 'b', GPART_PARAM_BOOTCODE, "", G_TYPE_STRING }, - { 'p', GPART_PARAM_PARTCODE, "", G_TYPE_STRING }, - { 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM }, + { 'b', GPART_PARAM_BOOTCODE, G_VAL_OPTIONAL, G_TYPE_STRING }, + { 'p', GPART_PARAM_PARTCODE, G_VAL_OPTIONAL, G_TYPE_STRING }, + { 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_ASCNUM }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "bootcode [-b bootcode] [-p partcode] [-i index] [-f flags] geom" @@ -109,7 +109,7 @@ struct g_command PUBSYM(class_commands)[] = { }, { "create", 0, gpart_issue, { { 's', "scheme", NULL, G_TYPE_STRING }, - { 'n', "entries", "", G_TYPE_ASCNUM }, + { 'n', "entries", G_VAL_OPTIONAL, G_TYPE_ASCNUM }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "-s scheme [-n entries] [-f flags] provider" @@ -127,8 +127,8 @@ struct g_command PUBSYM(class_commands)[] = { }, { "modify", 0, gpart_issue, { { 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM }, - { 'l', "label", "", G_TYPE_STRING }, - { 't', "type", "", G_TYPE_STRING }, + { 'l', "label", G_VAL_OPTIONAL, G_TYPE_STRING }, + { 't', "type", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "-i index [-l label] [-t type] [-f flags] geom" diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index 39731e964a34..d83a232e6785 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -374,9 +374,8 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc, warnx("Option '%c' not specified.", opt->go_char); usage(); - } else if (G_OPT_TYPE(opt) == G_TYPE_ASCNUM && - *(const char *)opt->go_val == '\0') { - ; /* add nothing. */ + } else if (opt->go_val == G_VAL_OPTIONAL) { + /* add nothing. */ } else { set_option(req, opt, opt->go_val); } diff --git a/sbin/geom/core/geom.h b/sbin/geom/core/geom.h index c88005ef10ad..a148ddaac7ad 100644 --- a/sbin/geom/core/geom.h +++ b/sbin/geom/core/geom.h @@ -53,6 +53,8 @@ #define G_OPT_NUM(opt) (((opt)->go_type & G_TYPE_NUMMASK) >> G_TYPE_NUMSHIFT) #define G_OPT_NUMINC(opt) ((opt)->go_type += (1 << G_TYPE_NUMSHIFT)) +#define G_VAL_OPTIONAL ((void *)-1) + #define G_OPT_SENTINEL { '\0', NULL, NULL, G_TYPE_NONE } #define G_NULL_OPTS { G_OPT_SENTINEL } #define G_CMD_SENTINEL { NULL, 0, NULL, G_NULL_OPTS, NULL }