summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-10-21 10:38:14 +0000
committerpjd <pjd@FreeBSD.org>2010-10-21 10:38:14 +0000
commitd92ab85359b3a1a5e37aa8bd3efe5a8e56191a4f (patch)
tree68add99cd5dbdd67e9561b078304530418259b03 /lib
parent78a51a15094e29f4b837cb5ed51f5d5020ddced6 (diff)
downloadFreeBSD-src-d92ab85359b3a1a5e37aa8bd3efe5a8e56191a4f.zip
FreeBSD-src-d92ab85359b3a1a5e37aa8bd3efe5a8e56191a4f.tar.gz
Remove code duplication by introducing static gctl_param_add() function which
is now used by both gctl_ro_param() and gctl_rw_param().
Diffstat (limited to 'lib')
-rw-r--r--lib/libgeom/geom_ctl.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/lib/libgeom/geom_ctl.c b/lib/libgeom/geom_ctl.c
index 3ede5f4..956169f 100644
--- a/lib/libgeom/geom_ctl.c
+++ b/lib/libgeom/geom_ctl.c
@@ -150,8 +150,9 @@ gctl_new_arg(struct gctl_req *req)
return (ap);
}
-void
-gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* value)
+static void
+gctl_param_add(struct gctl_req *req, const char *name, int len, void *value,
+ int flag)
{
struct gctl_req_arg *ap;
@@ -165,8 +166,8 @@ gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* value
if (ap->name == NULL)
return;
ap->nlen = strlen(ap->name) + 1;
- ap->value = __DECONST(void *, value);
- ap->flag = GCTL_PARAM_RD;
+ ap->value = value;
+ ap->flag = flag;
if (len >= 0)
ap->len = len;
else if (len < 0) {
@@ -176,26 +177,17 @@ gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* value
}
void
-gctl_rw_param(struct gctl_req *req, const char *name, int len, void* value)
+gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* value)
{
- struct gctl_req_arg *ap;
- if (req == NULL || req->error != NULL)
- return;
- ap = gctl_new_arg(req);
- if (ap == NULL)
- return;
- ap->name = strdup(name);
- gctl_check_alloc(req, ap->name);
- if (ap->name == NULL)
- return;
- ap->nlen = strlen(ap->name) + 1;
- ap->value = value;
- ap->flag = GCTL_PARAM_RW;
- if (len >= 0)
- ap->len = len;
- else if (len < 0)
- ap->len = strlen(value) + 1;
+ gctl_param_add(req, name, len, __DECONST(void *, value), GCTL_PARAM_RD);
+}
+
+void
+gctl_rw_param(struct gctl_req *req, const char *name, int len, void *value)
+{
+
+ gctl_param_add(req, name, len, value, GCTL_PARAM_RW);
}
const char *
OpenPOWER on IntegriCloud