Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Apr 2015 22:57:05 +0000 (UTC)
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r282257 - in head: lib/libnv sys/kern sys/sys
Message-ID:  <201504292257.t3TMv5A1091917@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oshogbo
Date: Wed Apr 29 22:57:04 2015
New Revision: 282257
URL: https://svnweb.freebsd.org/changeset/base/282257

Log:
  Remove the nvlist_.*[fv] functions.
  
  Those functions are problematic, because there is no way to report
  memory allocation problems without complicating the API, so we can
  either abort or potentially return invalid results. None of which is
  acceptable.
  
  In most cases the caller knows the size of the name, so he can allocate
  buffer on the stack and use snprintf(3) to prepare the name.
  
  After some discussion the conclusion is to removed those functions,
  which also simplifies the API.
  
  Discussed with: pjd, rstone
  Approved by:	pjd (mentor)

Modified:
  head/lib/libnv/Makefile
  head/sys/kern/subr_dnvlist.c
  head/sys/kern/subr_nvlist.c
  head/sys/kern/subr_nvpair.c
  head/sys/sys/nv.h
  head/sys/sys/nv_impl.h

Modified: head/lib/libnv/Makefile
==============================================================================
--- head/lib/libnv/Makefile	Wed Apr 29 22:50:41 2015	(r282256)
+++ head/lib/libnv/Makefile	Wed Apr 29 22:57:04 2015	(r282257)
@@ -81,88 +81,6 @@ MLINKS+=nv.3 nvlist_create.3 \
 	nv.3 nvlist_free_nvlist.3 \
 	nv.3 nvlist_free_descriptor.3 \
 	nv.3 nvlist_free_binary.3
-MLINKS+=nv.3 nvlist_existsf.3 \
-	nv.3 nvlist_existsf_type.3 \
-	nv.3 nvlist_existsf_null.3 \
-	nv.3 nvlist_existsf_bool.3 \
-	nv.3 nvlist_existsf_number.3 \
-	nv.3 nvlist_existsf_string.3 \
-	nv.3 nvlist_existsf_nvlist.3 \
-	nv.3 nvlist_existsf_descriptor.3 \
-	nv.3 nvlist_existsf_binary.3 \
-	nv.3 nvlist_addf_null.3 \
-	nv.3 nvlist_addf_bool.3 \
-	nv.3 nvlist_addf_number.3 \
-	nv.3 nvlist_addf_string.3 \
-	nv.3 nvlist_addf_nvlist.3 \
-	nv.3 nvlist_addf_descriptor.3 \
-	nv.3 nvlist_addf_binary.3 \
-	nv.3 nvlist_movef_string.3 \
-	nv.3 nvlist_movef_nvlist.3 \
-	nv.3 nvlist_movef_descriptor.3 \
-	nv.3 nvlist_movef_binary.3 \
-	nv.3 nvlist_getf_bool.3 \
-	nv.3 nvlist_getf_number.3 \
-	nv.3 nvlist_getf_string.3 \
-	nv.3 nvlist_getf_nvlist.3 \
-	nv.3 nvlist_getf_descriptor.3 \
-	nv.3 nvlist_getf_binary.3 \
-	nv.3 nvlist_takef_bool.3 \
-	nv.3 nvlist_takef_number.3 \
-	nv.3 nvlist_takef_string.3 \
-	nv.3 nvlist_takef_nvlist.3 \
-	nv.3 nvlist_takef_descriptor.3 \
-	nv.3 nvlist_takef_binary.3 \
-	nv.3 nvlist_freef.3 \
-	nv.3 nvlist_freef_type.3 \
-	nv.3 nvlist_freef_null.3 \
-	nv.3 nvlist_freef_bool.3 \
-	nv.3 nvlist_freef_number.3 \
-	nv.3 nvlist_freef_string.3 \
-	nv.3 nvlist_freef_nvlist.3 \
-	nv.3 nvlist_freef_descriptor.3 \
-	nv.3 nvlist_freef_binary.3
-MLINKS+=nv.3 nvlist_existsv.3 \
-	nv.3 nvlist_existsv_type.3 \
-	nv.3 nvlist_existsv_null.3 \
-	nv.3 nvlist_existsv_bool.3 \
-	nv.3 nvlist_existsv_number.3 \
-	nv.3 nvlist_existsv_string.3 \
-	nv.3 nvlist_existsv_nvlist.3 \
-	nv.3 nvlist_existsv_descriptor.3 \
-	nv.3 nvlist_existsv_binary.3 \
-	nv.3 nvlist_addv_null.3 \
-	nv.3 nvlist_addv_bool.3 \
-	nv.3 nvlist_addv_number.3 \
-	nv.3 nvlist_addv_string.3 \
-	nv.3 nvlist_addv_nvlist.3 \
-	nv.3 nvlist_addv_descriptor.3 \
-	nv.3 nvlist_addv_binary.3 \
-	nv.3 nvlist_movev_string.3 \
-	nv.3 nvlist_movev_nvlist.3 \
-	nv.3 nvlist_movev_descriptor.3 \
-	nv.3 nvlist_movev_binary.3 \
-	nv.3 nvlist_getv_bool.3 \
-	nv.3 nvlist_getv_number.3 \
-	nv.3 nvlist_getv_string.3 \
-	nv.3 nvlist_getv_nvlist.3 \
-	nv.3 nvlist_getv_descriptor.3 \
-	nv.3 nvlist_getv_binary.3 \
-	nv.3 nvlist_takev_bool.3 \
-	nv.3 nvlist_takev_number.3 \
-	nv.3 nvlist_takev_string.3 \
-	nv.3 nvlist_takev_nvlist.3 \
-	nv.3 nvlist_takev_descriptor.3 \
-	nv.3 nvlist_takev_binary.3 \
-	nv.3 nvlist_freev.3 \
-	nv.3 nvlist_freev_type.3 \
-	nv.3 nvlist_freev_null.3 \
-	nv.3 nvlist_freev_bool.3 \
-	nv.3 nvlist_freev_number.3 \
-	nv.3 nvlist_freev_string.3 \
-	nv.3 nvlist_freev_nvlist.3 \
-	nv.3 nvlist_freev_descriptor.3 \
-	nv.3 nvlist_freev_binary.3
 
 WARNS?=	6
 

Modified: head/sys/kern/subr_dnvlist.c
==============================================================================
--- head/sys/kern/subr_dnvlist.c	Wed Apr 29 22:50:41 2015	(r282256)
+++ head/sys/kern/subr_dnvlist.c	Wed Apr 29 22:57:04 2015	(r282257)
@@ -89,89 +89,6 @@ dnvlist_get_binary(const nvlist_t *nvl, 
 	return (value);
 }
 
-#ifndef _KERNEL
-#define	DNVLIST_GETF(ftype, type)					\
-ftype									\
-dnvlist_getf_##type(const nvlist_t *nvl, ftype defval,			\
-    const char *namefmt, ...)						\
-{									\
-	va_list nameap;							\
-	ftype value;							\
-									\
-	va_start(nameap, namefmt);					\
-	value = dnvlist_getv_##type(nvl, defval, namefmt, nameap);	\
-	va_end(nameap);							\
-									\
-	return (value);							\
-}
-
-DNVLIST_GETF(bool, bool)
-DNVLIST_GETF(uint64_t, number)
-DNVLIST_GETF(const char *, string)
-DNVLIST_GETF(const nvlist_t *, nvlist)
-DNVLIST_GETF(int, descriptor)
-
-#undef	DNVLIST_GETF
-
-const void *
-dnvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
-    size_t defsize, const char *namefmt, ...)
-{
-	va_list nameap;
-	const void *value;
-
-	va_start(nameap, namefmt);
-	value = dnvlist_getv_binary(nvl, sizep, defval, defsize, namefmt,
-	    nameap);
-	va_end(nameap);
-
-	return (value);
-}
-
-#define	DNVLIST_GETV(ftype, type)					\
-ftype									\
-dnvlist_getv_##type(const nvlist_t *nvl, ftype defval,			\
-    const char *namefmt, va_list nameap)				\
-{									\
-	char *name;							\
-	ftype value;							\
-									\
-	vasprintf(&name, namefmt, nameap);				\
-	if (name == NULL)						\
-		return (defval);					\
-	value = dnvlist_get_##type(nvl, name, defval);			\
-	free(name);							\
-	return (value);							\
-}
-
-DNVLIST_GETV(bool, bool)
-DNVLIST_GETV(uint64_t, number)
-DNVLIST_GETV(const char *, string)
-DNVLIST_GETV(const nvlist_t *, nvlist)
-DNVLIST_GETV(int, descriptor)
-
-#undef	DNVLIST_GETV
-
-const void *
-dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
-    size_t defsize, const char *namefmt, va_list nameap)
-{
-	char *name;
-	const void *value;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name != NULL) {
-		value = dnvlist_get_binary(nvl, name, sizep, defval, defsize);
-		nv_free(name);
-	} else {
-		if (sizep != NULL)
-			*sizep = defsize;
-		value = defval;
-	}
-	return (value);
-}
-#endif
-
 #define	DNVLIST_TAKE(ftype, type)					\
 ftype									\
 dnvlist_take_##type(nvlist_t *nvl, const char *name, ftype defval)	\
@@ -209,86 +126,3 @@ dnvlist_take_binary(nvlist_t *nvl, const
 	return (value);
 }
 
-#ifndef _KERNEL
-#define	DNVLIST_TAKEF(ftype, type)					\
-ftype									\
-dnvlist_takef_##type(nvlist_t *nvl, ftype defval,			\
-    const char *namefmt, ...)						\
-{									\
-	va_list nameap;							\
-	ftype value;							\
-									\
-	va_start(nameap, namefmt);					\
-	value = dnvlist_takev_##type(nvl, defval, namefmt, nameap);	\
-	va_end(nameap);							\
-									\
-	return (value);							\
-}
-
-DNVLIST_TAKEF(bool, bool)
-DNVLIST_TAKEF(uint64_t, number)
-DNVLIST_TAKEF(char *, string)
-DNVLIST_TAKEF(nvlist_t *, nvlist)
-DNVLIST_TAKEF(int, descriptor)
-
-#undef	DNVLIST_TAKEF
-
-void *
-dnvlist_takef_binary(nvlist_t *nvl, size_t *sizep, void *defval,
-    size_t defsize, const char *namefmt, ...)
-{
-	va_list nameap;
-	void *value;
-
-	va_start(nameap, namefmt);
-	value = dnvlist_takev_binary(nvl, sizep, defval, defsize, namefmt,
-	    nameap);
-	va_end(nameap);
-
-	return (value);
-}
-
-#define	DNVLIST_TAKEV(ftype, type)					\
-ftype									\
-dnvlist_takev_##type(nvlist_t *nvl, ftype defval, const char *namefmt,	\
-    va_list nameap)							\
-{									\
-	char *name;							\
-	ftype value;							\
-									\
-	vasprintf(&name, namefmt, nameap);				\
-	if (name == NULL)						\
-		return (defval);					\
-	value = dnvlist_take_##type(nvl, name, defval);			\
-	free(name);							\
-	return (value);							\
-}
-
-DNVLIST_TAKEV(bool, bool)
-DNVLIST_TAKEV(uint64_t, number)
-DNVLIST_TAKEV(char *, string)
-DNVLIST_TAKEV(nvlist_t *, nvlist)
-DNVLIST_TAKEV(int, descriptor)
-
-#undef	DNVLIST_TAKEV
-
-void *
-dnvlist_takev_binary(nvlist_t *nvl, size_t *sizep, void *defval,
-    size_t defsize, const char *namefmt, va_list nameap)
-{
-	char *name;
-	void *value;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name != NULL) {
-		value = dnvlist_take_binary(nvl, name, sizep, defval, defsize);
-		nv_free(name);
-	} else {
-		if (sizep != NULL)
-			*sizep = defsize;
-		value = defval;
-	}
-
-	return (value);
-}
-#endif

Modified: head/sys/kern/subr_nvlist.c
==============================================================================
--- head/sys/kern/subr_nvlist.c	Wed Apr 29 22:50:41 2015	(r282256)
+++ head/sys/kern/subr_nvlist.c	Wed Apr 29 22:57:04 2015	(r282257)
@@ -281,37 +281,6 @@ nvlist_exists_type(const nvlist_t *nvl, 
 	return (nvlist_find(nvl, type, name) != NULL);
 }
 
-#ifndef _KERNEL
-bool
-nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...)
-{
-	va_list nameap;
-	bool ret;
-
-	va_start(nameap, namefmt);
-	ret = nvlist_existsv_type(nvl, type, namefmt, nameap);
-	va_end(nameap);
-
-	return (ret);
-}
-
-bool
-nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt,
-    va_list nameap)
-{
-	char *name;
-	bool exists;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name == NULL)
-		return (false);
-
-	exists = nvlist_exists_type(nvl, name, type);
-	nv_free(name);
-	return (exists);
-}
-#endif
-
 void
 nvlist_free_type(nvlist_t *nvl, const char *name, int type)
 {
@@ -329,30 +298,6 @@ nvlist_free_type(nvlist_t *nvl, const ch
 		nvlist_report_missing(type, name);
 }
 
-#ifndef _KERNEL
-void
-nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_freev_type(nvl, type, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap)
-{
-	char *name;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name == NULL)
-		nvlist_report_missing(type, "<unknown>");
-	nvlist_free_type(nvl, name, type);
-	nv_free(name);
-}
-#endif
-
 nvlist_t *
 nvlist_clone(const nvlist_t *nvl)
 {
@@ -1099,86 +1044,6 @@ NVLIST_EXISTS(binary, BINARY)
 
 #undef	NVLIST_EXISTS
 
-#ifndef _KERNEL
-bool
-nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...)
-{
-	va_list nameap;
-	bool ret;
-
-	va_start(nameap, namefmt);
-	ret = nvlist_existsv(nvl, namefmt, nameap);
-	va_end(nameap);
-	return (ret);
-}
-
-#define	NVLIST_EXISTSF(type)						\
-bool									\
-nvlist_existsf_##type(const nvlist_t *nvl, const char *namefmt, ...)	\
-{									\
-	va_list nameap;							\
-	bool ret;							\
-									\
-	va_start(nameap, namefmt);					\
-	ret = nvlist_existsv_##type(nvl, namefmt, nameap);		\
-	va_end(nameap);							\
-	return (ret);							\
-}
-
-NVLIST_EXISTSF(null)
-NVLIST_EXISTSF(bool)
-NVLIST_EXISTSF(number)
-NVLIST_EXISTSF(string)
-NVLIST_EXISTSF(nvlist)
-#ifndef _KERNEL
-NVLIST_EXISTSF(descriptor)
-#endif
-NVLIST_EXISTSF(binary)
-
-#undef	NVLIST_EXISTSF
-
-bool
-nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap)
-{
-	char *name;
-	bool exists;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name == NULL)
-		return (false);
-
-	exists = nvlist_exists(nvl, name);
-	nv_free(name);
-	return (exists);
-}
-
-#define	NVLIST_EXISTSV(type)						\
-bool									\
-nvlist_existsv_##type(const nvlist_t *nvl, const char *namefmt,		\
-    va_list nameap)							\
-{									\
-	char *name;							\
-	bool exists;							\
-									\
-	vasprintf(&name, namefmt, nameap);				\
-	if (name == NULL)						\
-		return (false);						\
-	exists = nvlist_exists_##type(nvl, name);			\
-	free(name);							\
-	return (exists);						\
-}
-
-NVLIST_EXISTSV(null)
-NVLIST_EXISTSV(bool)
-NVLIST_EXISTSV(number)
-NVLIST_EXISTSV(string)
-NVLIST_EXISTSV(nvlist)
-NVLIST_EXISTSV(descriptor)
-NVLIST_EXISTSV(binary)
-
-#undef	NVLIST_EXISTSV
-#endif
-
 void
 nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
 {
@@ -1207,34 +1072,6 @@ nvlist_add_nvpair(nvlist_t *nvl, const n
 }
 
 void
-nvlist_add_null(nvlist_t *nvl, const char *name)
-{
-
-	nvlist_addf_null(nvl, "%s", name);
-}
-
-void
-nvlist_add_bool(nvlist_t *nvl, const char *name, bool value)
-{
-
-	nvlist_addf_bool(nvl, value, "%s", name);
-}
-
-void
-nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value)
-{
-
-	nvlist_addf_number(nvl, value, "%s", name);
-}
-
-void
-nvlist_add_string(nvlist_t *nvl, const char *name, const char *value)
-{
-
-	nvlist_addf_string(nvl, value, "%s", name);
-}
-
-void
 nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...)
 {
 	va_list valueap;
@@ -1265,105 +1102,7 @@ nvlist_add_stringv(nvlist_t *nvl, const 
 }
 
 void
-nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value)
-{
-
-	nvlist_addf_nvlist(nvl, value, "%s", name);
-}
-
-#ifndef _KERNEL
-void
-nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value)
-{
-
-	nvlist_addf_descriptor(nvl, value, "%s", name);
-}
-#endif
-
-void
-nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
-    size_t size)
-{
-
-	nvlist_addf_binary(nvl, value, size, "%s", name);
-}
-
-void
-nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_null(nvl, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_bool(nvl, value, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_number(nvl, value, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_string(nvl, value, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
-    ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_nvlist(nvl, value, namefmt, nameap);
-	va_end(nameap);
-}
-
-#ifndef _KERNEL
-void
-nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_descriptor(nvl, value, namefmt, nameap);
-	va_end(nameap);
-}
-#endif
-
-void
-nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size,
-    const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_addv_binary(nvl, value, size, namefmt, nameap);
-	va_end(nameap);
-}
-
-void
-nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap)
+nvlist_add_null(nvlist_t *nvl, const char *name)
 {
 	nvpair_t *nvp;
 
@@ -1372,7 +1111,7 @@ nvlist_addv_null(nvlist_t *nvl, const ch
 		return;
 	}
 
-	nvp = nvpair_createv_null(namefmt, nameap);
+	nvp = nvpair_create_null(name);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1382,7 +1121,7 @@ nvlist_addv_null(nvlist_t *nvl, const ch
 }
 
 void
-nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap)
+nvlist_add_bool(nvlist_t *nvl, const char *name, bool value)
 {
 	nvpair_t *nvp;
 
@@ -1391,7 +1130,7 @@ nvlist_addv_bool(nvlist_t *nvl, bool val
 		return;
 	}
 
-	nvp = nvpair_createv_bool(value, namefmt, nameap);
+	nvp = nvpair_create_bool(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1401,8 +1140,7 @@ nvlist_addv_bool(nvlist_t *nvl, bool val
 }
 
 void
-nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt,
-    va_list nameap)
+nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value)
 {
 	nvpair_t *nvp;
 
@@ -1411,7 +1149,7 @@ nvlist_addv_number(nvlist_t *nvl, uint64
 		return;
 	}
 
-	nvp = nvpair_createv_number(value, namefmt, nameap);
+	nvp = nvpair_create_number(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1421,8 +1159,7 @@ nvlist_addv_number(nvlist_t *nvl, uint64
 }
 
 void
-nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt,
-    va_list nameap)
+nvlist_add_string(nvlist_t *nvl, const char *name, const char *value)
 {
 	nvpair_t *nvp;
 
@@ -1431,7 +1168,7 @@ nvlist_addv_string(nvlist_t *nvl, const 
 		return;
 	}
 
-	nvp = nvpair_createv_string(value, namefmt, nameap);
+	nvp = nvpair_create_string(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1441,8 +1178,7 @@ nvlist_addv_string(nvlist_t *nvl, const 
 }
 
 void
-nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
-    va_list nameap)
+nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value)
 {
 	nvpair_t *nvp;
 
@@ -1451,7 +1187,7 @@ nvlist_addv_nvlist(nvlist_t *nvl, const 
 		return;
 	}
 
-	nvp = nvpair_createv_nvlist(value, namefmt, nameap);
+	nvp = nvpair_create_nvlist(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1462,8 +1198,7 @@ nvlist_addv_nvlist(nvlist_t *nvl, const 
 
 #ifndef _KERNEL
 void
-nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt,
-    va_list nameap)
+nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value)
 {
 	nvpair_t *nvp;
 
@@ -1472,7 +1207,7 @@ nvlist_addv_descriptor(nvlist_t *nvl, in
 		return;
 	}
 
-	nvp = nvpair_createv_descriptor(value, namefmt, nameap);
+	nvp = nvpair_create_descriptor(name, value);
 	if (nvp == NULL)
 		nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
 	else
@@ -1481,8 +1216,8 @@ nvlist_addv_descriptor(nvlist_t *nvl, in
 #endif
 
 void
-nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size,
-    const char *namefmt, va_list nameap)
+nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
+    size_t size)
 {
 	nvpair_t *nvp;
 
@@ -1491,7 +1226,7 @@ nvlist_addv_binary(nvlist_t *nvl, const 
 		return;
 	}
 
-	nvp = nvpair_createv_binary(value, size, namefmt, nameap);
+	nvp = nvpair_create_binary(name, value, size);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1522,63 +1257,8 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair
 	nvpair_insert(&nvl->nvl_head, nvp, nvl);
 }
 
-#define	NVLIST_MOVE(vtype, type)					\
-void									\
-nvlist_move_##type(nvlist_t *nvl, const char *name, vtype value)	\
-{									\
-									\
-	nvlist_movef_##type(nvl, value, "%s", name);			\
-}
-
-NVLIST_MOVE(char *, string)
-NVLIST_MOVE(nvlist_t *, nvlist)
-#ifndef _KERNEL
-NVLIST_MOVE(int, descriptor)
-#endif
-
-#undef	NVLIST_MOVE
-
-void
-nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
-{
-
-	nvlist_movef_binary(nvl, value, size, "%s", name);
-}
-
-#define	NVLIST_MOVEF(vtype, type)					\
-void									\
-nvlist_movef_##type(nvlist_t *nvl, vtype value, const char *namefmt,	\
-    ...)								\
-{									\
-	va_list nameap;							\
-									\
-	va_start(nameap, namefmt);					\
-	nvlist_movev_##type(nvl, value, namefmt, nameap);		\
-	va_end(nameap);							\
-}
-
-NVLIST_MOVEF(char *, string)
-NVLIST_MOVEF(nvlist_t *, nvlist)
-#ifndef _KERNEL
-NVLIST_MOVEF(int, descriptor)
-#endif
-
-#undef	NVLIST_MOVEF
-
-void
-nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size,
-    const char *namefmt, ...)
-{
-	va_list nameap;
-
-	va_start(nameap, namefmt);
-	nvlist_movev_binary(nvl, value, size, namefmt, nameap);
-	va_end(nameap);
-}
-
 void
-nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt,
-    va_list nameap)
+nvlist_move_string(nvlist_t *nvl, const char *name, char *value)
 {
 	nvpair_t *nvp;
 
@@ -1588,7 +1268,7 @@ nvlist_movev_string(nvlist_t *nvl, char 
 		return;
 	}
 
-	nvp = nvpair_movev_string(value, namefmt, nameap);
+	nvp = nvpair_move_string(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1598,8 +1278,7 @@ nvlist_movev_string(nvlist_t *nvl, char 
 }
 
 void
-nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt,
-    va_list nameap)
+nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value)
 {
 	nvpair_t *nvp;
 
@@ -1610,7 +1289,7 @@ nvlist_movev_nvlist(nvlist_t *nvl, nvlis
 		return;
 	}
 
-	nvp = nvpair_movev_nvlist(value, namefmt, nameap);
+	nvp = nvpair_move_nvlist(name, value);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1621,8 +1300,7 @@ nvlist_movev_nvlist(nvlist_t *nvl, nvlis
 
 #ifndef _KERNEL
 void
-nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt,
-    va_list nameap)
+nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value)
 {
 	nvpair_t *nvp;
 
@@ -1632,7 +1310,7 @@ nvlist_movev_descriptor(nvlist_t *nvl, i
 		return;
 	}
 
-	nvp = nvpair_movev_descriptor(value, namefmt, nameap);
+	nvp = nvpair_move_descriptor(name, value);
 	if (nvp == NULL)
 		nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
 	else
@@ -1641,8 +1319,7 @@ nvlist_movev_descriptor(nvlist_t *nvl, i
 #endif
 
 void
-nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size,
-    const char *namefmt, va_list nameap)
+nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
 {
 	nvpair_t *nvp;
 
@@ -1652,7 +1329,7 @@ nvlist_movev_binary(nvlist_t *nvl, void 
 		return;
 	}
 
-	nvp = nvpair_movev_binary(value, size, namefmt, nameap);
+	nvp = nvpair_move_binary(name, value, size);
 	if (nvp == NULL) {
 		nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
 		RESTORE_ERRNO(nvl->nvl_error);
@@ -1702,84 +1379,6 @@ nvlist_get_binary(const nvlist_t *nvl, c
 	return (nvpair_get_binary(nvp, sizep));
 }
 
-#define	NVLIST_GETF(ftype, type)					\
-ftype									\
-nvlist_getf_##type(const nvlist_t *nvl, const char *namefmt, ...)	\
-{									\
-	va_list nameap;							\
-	ftype value;							\
-									\
-	va_start(nameap, namefmt);					\
-	value = nvlist_getv_##type(nvl, namefmt, nameap);		\
-	va_end(nameap);							\
-									\
-	return (value);							\
-}
-
-#ifndef _KERNEL
-NVLIST_GETF(bool, bool)
-NVLIST_GETF(uint64_t, number)
-NVLIST_GETF(const char *, string)
-NVLIST_GETF(const nvlist_t *, nvlist)
-NVLIST_GETF(int, descriptor)
-
-#undef	NVLIST_GETF
-
-const void *
-nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
-{
-	va_list nameap;
-	const void *value;
-
-	va_start(nameap, namefmt);
-	value = nvlist_getv_binary(nvl, sizep, namefmt, nameap);
-	va_end(nameap);
-
-	return (value);
-}
-
-#define	NVLIST_GETV(ftype, type, TYPE)					\
-ftype									\
-nvlist_getv_##type(const nvlist_t *nvl, const char *namefmt,		\
-    va_list nameap)							\
-{									\
-	char *name;							\
-	ftype value;							\
-									\
-	vasprintf(&name, namefmt, nameap);				\
-	if (name == NULL)						\
-		nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>");	\
-	value = nvlist_get_##type(nvl, name);				\
-	free(name);							\
-									\
-	return (value);							\
-}
-
-NVLIST_GETV(bool, bool, BOOL)
-NVLIST_GETV(uint64_t, number, NUMBER)
-NVLIST_GETV(const char *, string, STRING)
-NVLIST_GETV(const nvlist_t *, nvlist, NVLIST)
-NVLIST_GETV(int, descriptor, DESCRIPTOR)
-
-#undef	NVLIST_GETV
-
-const void *
-nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt,
-    va_list nameap)
-{
-	char *name;
-	const void *binary;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name == NULL)
-		nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
-
-	binary = nvlist_get_binary(nvl, name, sizep);
-	nv_free(name);
-	return (binary);
-}
-#endif
-
 #define	NVLIST_TAKE(ftype, type, TYPE)					\
 ftype									\
 nvlist_take_##type(nvlist_t *nvl, const char *name)			\
@@ -1822,82 +1421,6 @@ nvlist_take_binary(nvlist_t *nvl, const 
 	return (value);
 }
 
-#define	NVLIST_TAKEF(ftype, type)					\
-ftype									\
-nvlist_takef_##type(nvlist_t *nvl, const char *namefmt, ...)		\
-{									\
-	va_list nameap;							\
-	ftype value;							\
-									\
-	va_start(nameap, namefmt);					\
-	value = nvlist_takev_##type(nvl, namefmt, nameap);		\
-	va_end(nameap);							\
-									\
-	return (value);							\
-}
-
-#ifndef _KERNEL
-NVLIST_TAKEF(bool, bool)
-NVLIST_TAKEF(uint64_t, number)
-NVLIST_TAKEF(char *, string)
-NVLIST_TAKEF(nvlist_t *, nvlist)
-NVLIST_TAKEF(int, descriptor)
-
-#undef	NVLIST_TAKEF
-
-void *
-nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
-{
-	va_list nameap;
-	void *value;
-
-	va_start(nameap, namefmt);
-	value = nvlist_takev_binary(nvl, sizep, namefmt, nameap);
-	va_end(nameap);
-
-	return (value);
-}
-
-#define	NVLIST_TAKEV(ftype, type, TYPE)					\
-ftype									\
-nvlist_takev_##type(nvlist_t *nvl, const char *namefmt, va_list nameap)	\
-{									\
-	char *name;							\
-	ftype value;							\
-									\
-	vasprintf(&name, namefmt, nameap);				\
-	if (name == NULL)						\
-		nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>");	\
-	value = nvlist_take_##type(nvl, name);				\
-	free(name);							\
-	return (value);							\
-}
-
-NVLIST_TAKEV(bool, bool, BOOL)
-NVLIST_TAKEV(uint64_t, number, NUMBER)
-NVLIST_TAKEV(char *, string, STRING)
-NVLIST_TAKEV(nvlist_t *, nvlist, NVLIST)
-NVLIST_TAKEV(int, descriptor, DESCRIPTOR)
-
-#undef	NVLIST_TAKEV
-
-void *
-nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt,
-    va_list nameap)
-{
-	char *name;
-	void *binary;
-
-	nv_vasprintf(&name, namefmt, nameap);
-	if (name == NULL)
-		nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
-
-	binary = nvlist_take_binary(nvl, name, sizep);
-	nv_free(name);
-	return (binary);
-}
-#endif
-
 void
 nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
 {
@@ -1936,68 +1459,6 @@ NVLIST_FREE(binary, BINARY)
 
 #undef	NVLIST_FREE
 
-#ifndef _KERNEL
-void
-nvlist_freef(nvlist_t *nvl, const char *namefmt, ...)
-{

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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