svn commit: r304909 - in head: lib/libnv/tests sys/contrib/libnv

Mariusz Zaborski oshogbo at FreeBSD.org
Sat Aug 27 13:40:29 UTC 2016


Author: oshogbo
Date: Sat Aug 27 13:40:27 2016
New Revision: 304909
URL: https://svnweb.freebsd.org/changeset/base/304909

Log:
  Fix style issue in the cnv API.
  Remove unused arguments in a macro.
  Remove unused typedef.

Modified:
  head/lib/libnv/tests/Makefile
  head/lib/libnv/tests/cnv_tests.cc
  head/sys/contrib/libnv/cnvlist.c

Modified: head/lib/libnv/tests/Makefile
==============================================================================
--- head/lib/libnv/tests/Makefile	Sat Aug 27 13:37:30 2016	(r304908)
+++ head/lib/libnv/tests/Makefile	Sat Aug 27 13:40:27 2016	(r304909)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 ATF_TESTS_CXX=	\
-	cnv_tests\
+	cnv_tests \
 	dnv_tests \
 	nv_array_tests \
 	nv_tests \

Modified: head/lib/libnv/tests/cnv_tests.cc
==============================================================================
--- head/lib/libnv/tests/cnv_tests.cc	Sat Aug 27 13:37:30 2016	(r304908)
+++ head/lib/libnv/tests/cnv_tests.cc	Sat Aug 27 13:40:27 2016	(r304909)
@@ -188,8 +188,9 @@ ATF_TEST_CASE_BODY(cnvlist_get_nvlist)
 	ATF_REQUIRE(nvlist_exists(nvl, key));
 	ATF_REQUIRE(nvlist_exists_nvlist(nvl, key));
 
-	/* Assuming nvlist_get_nvlist() is correct check if cnvlist returns the
-	 * same pointer.
+	/*
+	 * Assuming nvlist_get_nvlist() is correct check if cnvlist returns
+	 * the same pointer.
 	 */
 	result = cnvlist_get_nvlist(cookie);
 	ATF_REQUIRE_EQ(result, nvlist_get_nvlist(nvl, key));
@@ -499,7 +500,6 @@ ATF_TEST_CASE_BODY(cnvlist_get_nvlist_ar
 ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_descriptor_array);
 ATF_TEST_CASE_BODY(cnvlist_get_descriptor_array)
 {
-
 	nvlist_t *nvl;
 	size_t count, i, nitems;
 	const int *out_array;
@@ -730,7 +730,6 @@ ATF_TEST_CASE_BODY(cnvlist_take_nvlist)
 	ATF_REQUIRE(result == value);
 
 	/* Validate data inside nvlist. */
-
 	cookie = NULL;
 	ATF_REQUIRE_EQ(strcmp(subkey, nvlist_next(result, &type, &cookie)), 0);
 	ATF_REQUIRE_EQ(nvlist_error(value), 0);

Modified: head/sys/contrib/libnv/cnvlist.c
==============================================================================
--- head/sys/contrib/libnv/cnvlist.c	Sat Aug 27 13:37:30 2016	(r304908)
+++ head/sys/contrib/libnv/cnvlist.c	Sat Aug 27 13:40:27 2016	(r304909)
@@ -53,14 +53,15 @@ __FBSDID("$FreeBSD$");
 #include "nvlist_impl.h"
 #include "nvpair_impl.h"
 
-#define CNVLIST_GET(ftype, type, nvtype)				\
+#define	CNVLIST_GET(ftype, type, NVTYPE)				\
 ftype									\
 cnvlist_get_##type(void *cookiep)					\
 {									\
 									\
-        if (nvpair_type(cookiep) != NV_TYPE_##nvtype)			\
-		nvlist_report_missing(NV_TYPE_##nvtype,			\
+	if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) {			\
+		nvlist_report_missing(NV_TYPE_##NVTYPE,			\
 		    nvpair_name(cookiep));				\
+	}								\
         return (nvpair_get_##type(cookiep));				\
 }
 
@@ -72,17 +73,18 @@ CNVLIST_GET(const nvlist_t *, nvlist, NV
 CNVLIST_GET(int, descriptor, DESCRIPTOR)
 #endif
 
-#undef CNVLIST_GET
+#undef	CNVLIST_GET
 
-#define CNVLIST_GET_ARRAY(ftype, type, nvtype)				\
+#define	CNVLIST_GET_ARRAY(ftype, type, NVTYPE)				\
 ftype									\
 cnvlist_get_##type(void *cookiep, size_t *nitemsp)			\
 {									\
 									\
-        if (nvpair_type(cookiep) != NV_TYPE_##nvtype)			\
-		nvlist_report_missing(NV_TYPE_##nvtype,			\
+	if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) {			\
+		nvlist_report_missing(NV_TYPE_##NVTYPE,			\
 		    nvpair_name(cookiep));				\
-        return (nvpair_get_##type(cookiep, nitemsp));			\
+	}								\
+	return (nvpair_get_##type(cookiep, nitemsp));			\
 }
 
 CNVLIST_GET_ARRAY(const bool *, bool_array, BOOL_ARRAY)
@@ -93,26 +95,27 @@ CNVLIST_GET_ARRAY(const nvlist_t * const
 CNVLIST_GET_ARRAY(const int *, descriptor_array, DESCRIPTOR_ARRAY)
 #endif
 
-#undef  CNVLIST_GET_ARRAY
+#undef	CNVLIST_GET_ARRAY
 
 const void *
 cnvlist_get_binary(void *cookiep, size_t *sizep)
 {
 
-        if (nvpair_type(cookiep) != NV_TYPE_BINARY)
+	if (nvpair_type(cookiep) != NV_TYPE_BINARY)
 		nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookiep));
-        return (nvpair_get_binary(cookiep, sizep));
+	return (nvpair_get_binary(cookiep, sizep));
 }
 
-#define CNVLIST_TAKE(ftype, type, nvtype)				\
+#define CNVLIST_TAKE(ftype, type, NVTYPE)				\
 ftype									\
 cnvlist_take_##type(nvlist_t *nvl, void *cookiep)			\
 {									\
 	ftype value;							\
 									\
-        if (nvpair_type(cookiep) != NV_TYPE_##nvtype)			\
-		nvlist_report_missing(NV_TYPE_##nvtype,			\
+	if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) {			\
+		nvlist_report_missing(NV_TYPE_##NVTYPE,			\
 		    nvpair_name(cookiep));				\
+	}								\
 	value = (ftype)(intptr_t)nvpair_get_##type(cookiep);		\
 	nvlist_remove_nvpair(nvl, cookiep);				\
 	nvpair_free_structure(cookiep);					\
@@ -127,17 +130,18 @@ CNVLIST_TAKE(nvlist_t *, nvlist, NVLIST)
 CNVLIST_TAKE(int, descriptor, DESCRIPTOR)
 #endif
 
-#undef CNVLIST_TAKE
+#undef	CNVLIST_TAKE
 
-#define CNVLIST_TAKE_ARRAY(ftype, type, nvtype)				\
+#define	CNVLIST_TAKE_ARRAY(ftype, type, NVTYPE)				\
 ftype									\
 cnvlist_take_##type(nvlist_t *nvl, void *cookiep, size_t *nitemsp)	\
 {									\
 	ftype value;							\
 									\
-        if (nvpair_type(cookiep) != NV_TYPE_##nvtype)			\
-		nvlist_report_missing(NV_TYPE_##nvtype,			\
+	if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) {			\
+		nvlist_report_missing(NV_TYPE_##NVTYPE,			\
 		    nvpair_name(cookiep));				\
+	}								\
 	value = (ftype)(intptr_t)nvpair_get_##type(cookiep, nitemsp);	\
 	nvlist_remove_nvpair(nvl, cookiep);				\
 	nvpair_free_structure(cookiep);					\
@@ -152,14 +156,14 @@ CNVLIST_TAKE_ARRAY(nvlist_t **, nvlist_a
 CNVLIST_TAKE_ARRAY(int *, descriptor_array, DESCRIPTOR_ARRAY);
 #endif
 
-#undef  CNVLIST_TAKE_ARRAY
+#undef	CNVLIST_TAKE_ARRAY
 
 void *
 cnvlist_take_binary(nvlist_t *nvl, void *cookiep, size_t *sizep)
 {
-	void * value;
+	void *value;
 
-        if (nvpair_type(cookiep) != NV_TYPE_BINARY)
+	if (nvpair_type(cookiep) != NV_TYPE_BINARY)
 		nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookiep));
 	value = (void *)(intptr_t)nvpair_get_binary(cookiep, sizep);
 	nvlist_remove_nvpair(nvl, cookiep);
@@ -168,7 +172,7 @@ cnvlist_take_binary(nvlist_t *nvl, void 
 }
 
 
-#define CNVLIST_FREE(type, nvtype)					\
+#define	CNVLIST_FREE(type)						\
 void									\
 cnvlist_free_##type(nvlist_t *nvl, void *cookiep)			\
 {									\
@@ -176,18 +180,18 @@ cnvlist_free_##type(nvlist_t *nvl, void 
 	nvlist_free_nvpair(nvl, cookiep);				\
 }
 
-CNVLIST_FREE(bool, BOOL)
-CNVLIST_FREE(number, NUMBER)
-CNVLIST_FREE(string, STRING)
-CNVLIST_FREE(nvlist, NVLIST)
-CNVLIST_FREE(binary, BINARY);
-CNVLIST_FREE(bool_array, BOOL_ARRAY)
-CNVLIST_FREE(number_array, NUMBER_ARRAY)
-CNVLIST_FREE(string_array, STRING_ARRAY)
-CNVLIST_FREE(nvlist_array, NVLIST_ARRAY)
+CNVLIST_FREE(bool)
+CNVLIST_FREE(number)
+CNVLIST_FREE(string)
+CNVLIST_FREE(nvlist)
+CNVLIST_FREE(binary);
+CNVLIST_FREE(bool_array)
+CNVLIST_FREE(number_array)
+CNVLIST_FREE(string_array)
+CNVLIST_FREE(nvlist_array)
 #ifndef _KERNEL
-CNVLIST_FREE(descriptor, DESCRIPTOR)
-CNVLIST_FREE(descriptor_array, DESCRIPTOR_ARRAY)
+CNVLIST_FREE(descriptor)
+CNVLIST_FREE(descriptor_array)
 #endif
 
-#undef CNVLIST_FREE
+#undef	CNVLIST_FREE


More information about the svn-src-head mailing list