aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2020-07-22 02:14:27 +0000
committerXin LI <delphij@FreeBSD.org>2020-07-22 02:14:27 +0000
commit0ab851aac3a028d0771e6d32054b8b768a2bec3b (patch)
tree9d8886d29ac0603acd087915cbaef9efac307677
parent9d6d8bf8c74641895e7545c5adf1440f517377ae (diff)
downloadsrc-0ab851aac3a028d0771e6d32054b8b768a2bec3b.tar.gz
src-0ab851aac3a028d0771e6d32054b8b768a2bec3b.zip
gctl_get_class, gctl_get_geom and gctl_get_provider: provide feedback
when the requested argument is missing. Reviewed by: cem MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D25738
Notes
Notes: svn path=/head/; revision=363410
-rw-r--r--sys/geom/geom_ctl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c
index cdf0eddd3446..8b9af1aa54ab 100644
--- a/sys/geom/geom_ctl.c
+++ b/sys/geom/geom_ctl.c
@@ -396,12 +396,15 @@ gctl_get_class(struct gctl_req *req, char const *arg)
struct g_class *cp;
p = gctl_get_asciiparam(req, arg);
- if (p == NULL)
+ if (p == NULL) {
+ gctl_error(req, "Missing %s argument", arg);
return (NULL);
+ }
LIST_FOREACH(cp, &g_classes, class) {
if (!strcmp(p, cp->name))
return (cp);
}
+ gctl_error(req, "Class not found: \"%s\"", p);
return (NULL);
}
@@ -413,8 +416,10 @@ gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char const *arg)
struct g_geom *gp;
p = gctl_get_asciiparam(req, arg);
- if (p == NULL)
+ if (p == NULL) {
+ gctl_error(req, "Missing %s argument", arg);
return (NULL);
+ }
LIST_FOREACH(mp, &g_classes, class) {
if (mpr != NULL && mpr != mp)
continue;
@@ -434,8 +439,10 @@ gctl_get_provider(struct gctl_req *req, char const *arg)
struct g_provider *pp;
p = gctl_get_asciiparam(req, arg);
- if (p == NULL)
+ if (p == NULL) {
+ gctl_error(req, "Missing '%s' argument", arg);
return (NULL);
+ }
pp = g_provider_by_name(p);
if (pp != NULL)
return (pp);
@@ -453,10 +460,8 @@ g_ctl_req(void *arg, int flag __unused)
g_topology_assert();
req = arg;
mp = gctl_get_class(req, "class");
- if (mp == NULL) {
- gctl_error(req, "Class not found");
+ if (mp == NULL)
return;
- }
if (mp->ctlreq == NULL) {
gctl_error(req, "Class takes no requests");
return;