From owner-svn-src-head@freebsd.org Mon Jun 18 21:27:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 059E71023443; Mon, 18 Jun 2018 21:27:00 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC02774540; Mon, 18 Jun 2018 21:26:59 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74AE41AC5; Mon, 18 Jun 2018 21:26:59 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5ILQx4L090376; Mon, 18 Jun 2018 21:26:59 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5ILQwCZ090372; Mon, 18 Jun 2018 21:26:58 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201806182126.w5ILQwCZ090372@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Mon, 18 Jun 2018 21:26:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335343 - in head: lib/libnv/tests share/man/man9 sys/contrib/libnv sys/sys X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in head: lib/libnv/tests share/man/man9 sys/contrib/libnv sys/sys X-SVN-Commit-Revision: 335343 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2018 21:27:00 -0000 Author: oshogbo Date: Mon Jun 18 21:26:58 2018 New Revision: 335343 URL: https://svnweb.freebsd.org/changeset/base/335343 Log: 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 Modified: head/lib/libnv/tests/cnv_tests.cc head/share/man/man9/cnv.9 head/sys/contrib/libnv/cnvlist.c head/sys/sys/cnv.h Modified: head/lib/libnv/tests/cnv_tests.cc ============================================================================== --- head/lib/libnv/tests/cnv_tests.cc Mon Jun 18 21:23:40 2018 (r335342) +++ head/lib/libnv/tests/cnv_tests.cc Mon Jun 18 21:26:58 2018 (r335343) @@ -575,7 +575,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_bool) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - ATF_REQUIRE_EQ(cnvlist_take_bool(nvl, cookie), value); + ATF_REQUIRE_EQ(cnvlist_take_bool(cookie), value); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -618,7 +618,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_number) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - ATF_REQUIRE_EQ(cnvlist_take_number(nvl, cookie), value); + ATF_REQUIRE_EQ(cnvlist_take_number(cookie), value); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -662,7 +662,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_string) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_string = cnvlist_take_string(nvl, cookie); + out_string = cnvlist_take_string(cookie); ATF_REQUIRE(out_string != NULL); ATF_REQUIRE_EQ(strcmp(out_string, value), 0); @@ -725,7 +725,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_nvlist) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - result = cnvlist_take_nvlist(nvl, cookie); + result = cnvlist_take_nvlist(cookie); ATF_REQUIRE(!nvlist_exists_nvlist(nvl, key)); ATF_REQUIRE(result == value); @@ -784,7 +784,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_bool_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_bool_array(nvl, cookie, &nitems); + out_array = cnvlist_take_bool_array(cookie, &nitems); ATF_REQUIRE_EQ(nitems, 16); ATF_REQUIRE(out_array != NULL); for (i = 0; i < 16; i++) @@ -836,7 +836,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_number_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_number_array(nvl, cookie, &nitems); + out_array = cnvlist_take_number_array(cookie, &nitems); ATF_REQUIRE(out_array != NULL); ATF_REQUIRE_EQ(nitems, 16); @@ -885,7 +885,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_string_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_string_array(nvl, cookie, &nitems); + out_array = cnvlist_take_string_array(cookie, &nitems); ATF_REQUIRE_EQ(nitems, 4); for (i = 0; i < 4; i++) { ATF_REQUIRE(out_array[i] != NULL); @@ -957,7 +957,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_nvlist_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - result = cnvlist_take_nvlist_array(nvl, cookie, &num_items); + result = cnvlist_take_nvlist_array(cookie, &num_items); ATF_REQUIRE(result != NULL); ATF_REQUIRE_EQ(num_items, 8); @@ -1022,7 +1022,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_binary) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_binary = cnvlist_take_binary(nvl, cookie, &out_size); + out_binary = cnvlist_take_binary(cookie, &out_size); ATF_REQUIRE_EQ(out_size, in_size); ATF_REQUIRE_EQ(memcmp(in_binary, out_binary, out_size), 0); @@ -1069,7 +1069,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_bool) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_bool(nvl, cookie); + cnvlist_free_bool(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1112,7 +1112,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_number) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_number(nvl, cookie); + cnvlist_free_number(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1155,7 +1155,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_string) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_string(nvl, cookie); + cnvlist_free_string(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1215,7 +1215,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_nvlist) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_nvlist(nvl, cookie); + cnvlist_free_nvlist(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1262,7 +1262,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_binary) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_binary(nvl, cookie); + cnvlist_free_binary(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1309,7 +1309,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_bool_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_bool_array(nvl, cookie); + cnvlist_free_bool_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1354,7 +1354,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_number_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_number_array(nvl, cookie); + cnvlist_free_number_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1396,7 +1396,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_string_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_string_array(nvl, cookie); + cnvlist_free_string_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1459,7 +1459,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_nvlist_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_nvlist_array(nvl, cookie); + cnvlist_free_nvlist_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); Modified: head/share/man/man9/cnv.9 ============================================================================== --- head/share/man/man9/cnv.9 Mon Jun 18 21:23:40 2018 (r335342) +++ head/share/man/man9/cnv.9 Mon Jun 18 21:26:58 2018 (r335343) @@ -66,52 +66,52 @@ .Fn cnvlist_get_descriptor_array "const void *cookie" "size_t *nitemsp" .\" .Ft bool -.Fn cnvlist_take_bool "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_take_bool "void *cookie" .Ft uint64_t -.Fn cnvlist_take_number "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_take_number "void *cookie" .Ft "const char *" -.Fn cnvlist_take_string "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_take_string "void *cookie" .Ft "const nvlist_t *" -.Fn cnvlist_take_nvlist "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_take_nvlist "void *cookie" .Ft "const void *" -.Fn cnvlist_take_binary "nvlist_t *nvl" "void *cookie" "size_t *sizep" +.Fn cnvlist_take_binary "void *cookie" "size_t *sizep" .Ft "const bool *" -.Fn cnvlist_take_bool_array "nvlist_t *nvl" "void *cookie" "size_t *nitemsp" +.Fn cnvlist_take_bool_array "void *cookie" "size_t *nitemsp" .Ft "const uint64_t *" -.Fn cnvlist_take_number_array "nvlist_t *nvl" "void *cookie" "size_t *nitemsp" +.Fn cnvlist_take_number_array "void *cookie" "size_t *nitemsp" .Ft "const char * const *" -.Fn cnvlist_take_string_array "nvlist_t *nvl" "void *cookie" "size_t *nitemsp" +.Fn cnvlist_take_string_array "void *cookie" "size_t *nitemsp" .Ft "const nvlist_t * const *" -.Fn cnvlist_take_nvlist_array "nvlist_t *nvl" "void *cookie" "size_t *nitemsp" +.Fn cnvlist_take_nvlist_array "void *cookie" "size_t *nitemsp" .Ft int -.Fn cnvlist_take_descriptor "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_take_descriptor "void *cookie" .Ft "const int *" -.Fn cnvlist_take_descriptor_array "nvlist_t *nvl" "void *cookie" "size_t *nitemsp" +.Fn cnvlist_take_descriptor_array "void *cookie" "size_t *nitemsp" .\" .Ft void -.Fn cnvlist_free_null "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_null "void *cookie" .Ft void -.Fn cnvlist_free_bool "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_bool "void *cookie" .Ft void -.Fn cnvlist_free_number "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_number "void *cookie" .Ft void -.Fn cnvlist_free_string "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_string "void *cookie" .Ft void -.Fn cnvlist_free_nvlist "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_nvlist "void *cookie" .Ft void -.Fn cnvlist_free_descriptor "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_descriptor "void *cookie" .Ft void -.Fn cnvlist_free_binary "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_binary "void *cookie" .Ft void -.Fn cnvlist_free_bool_array "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_bool_array "void *cookie" .Ft void -.Fn cnvlist_free_number_array "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_number_array "void *cookie" .Ft void -.Fn cnvlist_free_string_array "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_string_array "void *cookie" .Ft void -.Fn cnvlist_free_nvlist_array "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_nvlist_array "void *cookie" .Ft void -.Fn cnvlist_free_descriptor_array "nvlist_t *nvl" "void *cookie" +.Fn cnvlist_free_descriptor_array "void *cookie" .Sh DESCRIPTION The .Nm libnv @@ -192,8 +192,8 @@ while (nvlist_next(nvl, &type, &cookie) != NULL) { } } -name = cnvlist_take_string(nvl, scookie); -cnvlist_free_bool(nvl, bcookie); +name = cnvlist_take_string(scookie); +cnvlist_free_bool(bcookie); printf("test2: %s\\n", name); free(name); Modified: head/sys/contrib/libnv/cnvlist.c ============================================================================== --- head/sys/contrib/libnv/cnvlist.c Mon Jun 18 21:23:40 2018 (r335342) +++ head/sys/contrib/libnv/cnvlist.c Mon Jun 18 21:26:58 2018 (r335343) @@ -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 #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_ #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) Modified: head/sys/sys/cnv.h ============================================================================== --- head/sys/sys/cnv.h Mon Jun 18 21:23:40 2018 (r335342) +++ head/sys/sys/cnv.h Mon Jun 18 21:26:58 2018 (r335343) @@ -82,18 +82,18 @@ const int *cnvlist_get_descriptor_array(const void *c * 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, v * 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