Date: Thu, 21 Oct 2010 10:38:14 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r214129 - head/lib/libgeom Message-ID: <201010211038.o9LAcEEs088213@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pjd Date: Thu Oct 21 10:38:14 2010 New Revision: 214129 URL: http://svn.freebsd.org/changeset/base/214129 Log: Remove code duplication by introducing static gctl_param_add() function which is now used by both gctl_ro_param() and gctl_rw_param(). Modified: head/lib/libgeom/geom_ctl.c Modified: head/lib/libgeom/geom_ctl.c ============================================================================== --- head/lib/libgeom/geom_ctl.c Thu Oct 21 10:36:36 2010 (r214128) +++ head/lib/libgeom/geom_ctl.c Thu Oct 21 10:38:14 2010 (r214129) @@ -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, cons 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, cons } 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 *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010211038.o9LAcEEs088213>