Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Oct 2019 21:49:40 +0000 (UTC)
From:      Chuck Silvers <chs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r353667 - head/sys/geom
Message-ID:  <201910162149.x9GLne2i027547@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: chs
Date: Wed Oct 16 21:49:39 2019
New Revision: 353667
URL: https://svnweb.freebsd.org/changeset/base/353667

Log:
  Add a new gctl_get_paraml_opt() interface to extract optional parameters from
  the request.  It is the same as gctl_get_paraml() except that the request
  is not marked with an error if the parameter is not present.
  
  Approved by:	imp (mentor)
  Reviewed by:	cem
  Sponsored by:	Netflix
  Differential Revision:	https://reviews.freebsd.org/D21972

Modified:
  head/sys/geom/geom.h
  head/sys/geom/geom_ctl.c

Modified: head/sys/geom/geom.h
==============================================================================
--- head/sys/geom/geom.h	Wed Oct 16 21:47:58 2019	(r353666)
+++ head/sys/geom/geom.h	Wed Oct 16 21:49:39 2019	(r353667)
@@ -428,6 +428,7 @@ void gctl_set_param_err(struct gctl_req *req, const ch
 void *gctl_get_param(struct gctl_req *req, const char *param, int *len);
 char const *gctl_get_asciiparam(struct gctl_req *req, const char *param);
 void *gctl_get_paraml(struct gctl_req *req, const char *param, int len);
+void *gctl_get_paraml_opt(struct gctl_req *req, const char *param, int len);
 int gctl_error(struct gctl_req *req, const char *fmt, ...) __printflike(2, 3);
 struct g_class *gctl_get_class(struct gctl_req *req, char const *arg);
 struct g_geom *gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char const *arg);

Modified: head/sys/geom/geom_ctl.c
==============================================================================
--- head/sys/geom/geom_ctl.c	Wed Oct 16 21:47:58 2019	(r353666)
+++ head/sys/geom/geom_ctl.c	Wed Oct 16 21:49:39 2019	(r353667)
@@ -365,18 +365,27 @@ gctl_get_asciiparam(struct gctl_req *req, const char *
 }
 
 void *
-gctl_get_paraml(struct gctl_req *req, const char *param, int len)
+gctl_get_paraml_opt(struct gctl_req *req, const char *param, int len)
 {
 	int i;
 	void *p;
 
 	p = gctl_get_param(req, param, &i);
-	if (p == NULL)
-		gctl_error(req, "Missing %s argument", param);
-	else if (i != len) {
+	if (i != len) {
 		p = NULL;
 		gctl_error(req, "Wrong length %s argument", param);
 	}
+	return (p);
+}
+
+void *
+gctl_get_paraml(struct gctl_req *req, const char *param, int len)
+{
+	void *p;
+
+	p = gctl_get_paraml_opt(req, param, len);
+	if (p == NULL)
+		gctl_error(req, "Missing %s argument", param);
 	return (p);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910162149.x9GLne2i027547>