1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-21 15:45:02 +00:00

Fix style issue in the cnv API.

Remove unused arguments in a macro.
Remove unused typedef.
This commit is contained in:
Mariusz Zaborski 2016-08-27 13:40:27 +00:00
parent 5ef231f6f7
commit 736bc73796
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=304909
3 changed files with 42 additions and 39 deletions

View File

@ -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_array)
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);

View File

@ -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)); \
}
@ -74,14 +75,15 @@ CNVLIST_GET(int, descriptor, DESCRIPTOR)
#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)); \
}
@ -104,15 +106,16 @@ cnvlist_get_binary(void *cookiep, size_t *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); \
@ -129,15 +132,16 @@ CNVLIST_TAKE(int, descriptor, DESCRIPTOR)
#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); \
@ -168,7 +172,7 @@ cnvlist_take_binary(nvlist_t *nvl, void *cookiep, size_t *sizep)
}
#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 *cookiep) \
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