aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2018-06-18 21:26:58 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2018-06-18 21:26:58 +0000
commitd82e41b6b82113e242b02f7a0193c6e6b26d495f (patch)
treea545b6becf82095b67d163153b86e7fab0f24db9 /sys
parent30665f3c42302105793ba18027ec02fd24801b9e (diff)
downloadsrc-d82e41b6b82113e242b02f7a0193c6e6b26d495f.tar.gz
src-d82e41b6b82113e242b02f7a0193c6e6b26d495f.zip
libnv: Remove nvlist argument from cnvlist_{take,free}_* functions.
All information which are need for those operations is already stored in the cookie. We decided not to bump libnv version because this API is not used yet in the base system. Reviewed by: pjd
Notes
Notes: svn path=/head/; revision=335343
Diffstat (limited to 'sys')
-rw-r--r--sys/contrib/libnv/cnvlist.c16
-rw-r--r--sys/sys/cnv.h44
2 files changed, 33 insertions, 27 deletions
diff --git a/sys/contrib/libnv/cnvlist.c b/sys/contrib/libnv/cnvlist.c
index 2a1134855df7..a35ddc482105 100644
--- a/sys/contrib/libnv/cnvlist.c
+++ b/sys/contrib/libnv/cnvlist.c
@@ -124,14 +124,16 @@ cnvlist_get_binary(const void *cookie, size_t *sizep)
#define CNVLIST_TAKE(ftype, type, NVTYPE) \
ftype \
-cnvlist_take_##type(nvlist_t *nvl, void *cookie) \
+cnvlist_take_##type(void *cookie) \
{ \
ftype value; \
+ nvlist_t *nvl; \
\
if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \
nvlist_report_missing(NV_TYPE_##NVTYPE, \
nvpair_name(cookie)); \
} \
+ nvl = nvpair_nvlist(cookie); \
value = (ftype)(intptr_t)nvpair_get_##type(cookie); \
nvlist_remove_nvpair(nvl, cookie); \
nvpair_free_structure(cookie); \
@@ -150,14 +152,16 @@ CNVLIST_TAKE(int, descriptor, DESCRIPTOR)
#define CNVLIST_TAKE_ARRAY(ftype, type, NVTYPE) \
ftype \
-cnvlist_take_##type(nvlist_t *nvl, void *cookie, size_t *nitemsp) \
+cnvlist_take_##type(void *cookie, size_t *nitemsp) \
{ \
ftype value; \
+ nvlist_t *nvl; \
\
if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \
nvlist_report_missing(NV_TYPE_##NVTYPE, \
nvpair_name(cookie)); \
} \
+ nvl = nvpair_nvlist(cookie); \
value = (ftype)(intptr_t)nvpair_get_##type(cookie, nitemsp); \
nvlist_remove_nvpair(nvl, cookie); \
nvpair_free_structure(cookie); \
@@ -175,12 +179,14 @@ CNVLIST_TAKE_ARRAY(int *, descriptor_array, DESCRIPTOR_ARRAY);
#undef CNVLIST_TAKE_ARRAY
void *
-cnvlist_take_binary(nvlist_t *nvl, void *cookie, size_t *sizep)
+cnvlist_take_binary(void *cookie, size_t *sizep)
{
void *value;
+ nvlist_t *nvl;
if (nvpair_type(cookie) != NV_TYPE_BINARY)
nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookie));
+ nvl = nvpair_nvlist(cookie);
value = (void *)(intptr_t)nvpair_get_binary(cookie, sizep);
nvlist_remove_nvpair(nvl, cookie);
nvpair_free_structure(cookie);
@@ -190,10 +196,10 @@ cnvlist_take_binary(nvlist_t *nvl, void *cookie, size_t *sizep)
#define CNVLIST_FREE(type) \
void \
-cnvlist_free_##type(nvlist_t *nvl, void *cookie) \
+cnvlist_free_##type(void *cookie) \
{ \
\
- nvlist_free_nvpair(nvl, cookie); \
+ nvlist_free_nvpair(nvpair_nvlist(cookie), cookie); \
}
CNVLIST_FREE(bool)
diff --git a/sys/sys/cnv.h b/sys/sys/cnv.h
index 9ce8bc4807a6..1e56cfbedd90 100644
--- a/sys/sys/cnv.h
+++ b/sys/sys/cnv.h
@@ -82,18 +82,18 @@ const int *cnvlist_get_descriptor_array(const void *cookie, size_t *nitemsp);
* The caller is responsible for freeing received data.
*/
-bool cnvlist_take_bool(nvlist_t *nvl, void *cookie);
-uint64_t cnvlist_take_number(nvlist_t *nvl, void *cookie);
-char *cnvlist_take_string(nvlist_t *nvl, void *cookie);
-nvlist_t *cnvlist_take_nvlist(nvlist_t *nvl, void *cookie);
-void *cnvlist_take_binary(nvlist_t *nvl, void *cookie, size_t *sizep);
-bool *cnvlist_take_bool_array(nvlist_t *nvl, void *cookie, size_t *nitemsp);
-uint64_t *cnvlist_take_number_array(nvlist_t *nvl, void *cookie, size_t *nitemsp);
-char **cnvlist_take_string_array(nvlist_t *nvl, void *cookie, size_t *nitemsp);
-nvlist_t **cnvlist_take_nvlist_array(nvlist_t *nvl, void *cookie, size_t *nitemsp);
+bool cnvlist_take_bool(void *cookie);
+uint64_t cnvlist_take_number(void *cookie);
+char *cnvlist_take_string(void *cookie);
+nvlist_t *cnvlist_take_nvlist(void *cookie);
+void *cnvlist_take_binary(void *cookie, size_t *sizep);
+bool *cnvlist_take_bool_array(void *cookie, size_t *nitemsp);
+uint64_t *cnvlist_take_number_array(void *cookie, size_t *nitemsp);
+char **cnvlist_take_string_array(void *cookie, size_t *nitemsp);
+nvlist_t **cnvlist_take_nvlist_array(void *cookie, size_t *nitemsp);
#ifndef _KERNEL
-int cnvlist_take_descriptor(nvlist_t *nvl, void *cookie);
-int *cnvlist_take_descriptor_array(nvlist_t *nvl, void *cookie, size_t *nitemsp);
+int cnvlist_take_descriptor(void *cookie);
+int *cnvlist_take_descriptor_array(void *cookie, size_t *nitemsp);
#endif
/*
@@ -101,18 +101,18 @@ int *cnvlist_take_descriptor_array(nvlist_t *nvl, void *cookie, size_t *nitem
* and frees memory associated with it.
*/
-void cnvlist_free_bool(nvlist_t *nvl, void *cookie);
-void cnvlist_free_number(nvlist_t *nvl, void *cookie);
-void cnvlist_free_string(nvlist_t *nvl, void *cookie);
-void cnvlist_free_nvlist(nvlist_t *nvl, void *cookie);
-void cnvlist_free_binary(nvlist_t *nvl, void *cookie);
-void cnvlist_free_bool_array(nvlist_t *nvl, void *cookie);
-void cnvlist_free_number_array(nvlist_t *nvl, void *cookie);
-void cnvlist_free_string_array(nvlist_t *nvl, void *cookie);
-void cnvlist_free_nvlist_array(nvlist_t *nvl, void *cookie);
+void cnvlist_free_bool(void *cookie);
+void cnvlist_free_number(void *cookie);
+void cnvlist_free_string(void *cookie);
+void cnvlist_free_nvlist(void *cookie);
+void cnvlist_free_binary(void *cookie);
+void cnvlist_free_bool_array(void *cookie);
+void cnvlist_free_number_array(void *cookie);
+void cnvlist_free_string_array(void *cookie);
+void cnvlist_free_nvlist_array(void *cookie);
#ifndef _KERNEL
-void cnvlist_free_descriptor(nvlist_t *nvl, void *cookie);
-void cnvlist_free_descriptor_array(nvlist_t *nvl, void *cookie);
+void cnvlist_free_descriptor(void *cookie);
+void cnvlist_free_descriptor_array(void *cookie);
#endif
__END_DECLS