From owner-svn-src-head@freebsd.org Thu Oct 26 20:44:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0A24E52D91; Thu, 26 Oct 2017 20:44:43 +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 mx1.freebsd.org (Postfix) with ESMTPS id 8ADAB692D1; Thu, 26 Oct 2017 20:44:43 +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 v9QKigpC055661; Thu, 26 Oct 2017 20:44:42 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9QKigHZ055658; Thu, 26 Oct 2017 20:44:42 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710262044.v9QKigHZ055658@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Thu, 26 Oct 2017 20:44:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325019 - in head: share/man/man9 sys/contrib/libnv sys/sys X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in head: share/man/man9 sys/contrib/libnv sys/sys X-SVN-Commit-Revision: 325019 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.23 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: Thu, 26 Oct 2017 20:44:43 -0000 Author: oshogbo Date: Thu Oct 26 20:44:42 2017 New Revision: 325019 URL: https://svnweb.freebsd.org/changeset/base/325019 Log: Introduce cnvlist_name() and cnvlist_type() functions. Those function can be used when we are iterating over nvlist to reduce amount of extra variables we need to declare. MFC after: 1 month Modified: head/share/man/man9/cnv.9 head/sys/contrib/libnv/cnvlist.c head/sys/sys/cnv.h Modified: head/share/man/man9/cnv.9 ============================================================================== --- head/share/man/man9/cnv.9 Thu Oct 26 19:45:15 2017 (r325018) +++ head/share/man/man9/cnv.9 Thu Oct 26 20:44:42 2017 (r325019) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 27, 2016 +.Dd October 26, 2017 .Dt CNV 9 .Os .Sh NAME @@ -37,6 +37,11 @@ .Lb libnv .Sh SYNOPSIS .In sys/cnv.h +.Ft const char * +.Fn cnvlist_name "void *cookiep" +.Ft int +.Fn cnvlist_type "void *cookiep" +.\" .Ft bool .Fn cnvlist_get_bool "void *cookiep" .Ft uint64_t @@ -121,6 +126,16 @@ The concept of cookies is explained in and .Fn nvlist_get_pararr from +.Xr nv 9 . +.Pp +The +.Fn cnvlist_name +function returns the name of an element associated with the given cookie. +.Pp +The +.Fn cnvlist_type +function returns the type of an element associated with the given cookie. +Types which can be returned are described in .Xr nv 9 . .Pp The Modified: head/sys/contrib/libnv/cnvlist.c ============================================================================== --- head/sys/contrib/libnv/cnvlist.c Thu Oct 26 19:45:15 2017 (r325018) +++ head/sys/contrib/libnv/cnvlist.c Thu Oct 26 20:44:42 2017 (r325019) @@ -53,6 +53,20 @@ __FBSDID("$FreeBSD$"); #include "nvlist_impl.h" #include "nvpair_impl.h" +const char * +cnvlist_name(void *cookiep) +{ + + return (nvpair_name(cookiep)); +} + +int +cnvlist_type(void *cookiep) +{ + + return (nvpair_type(cookiep)); +} + #define CNVLIST_GET(ftype, type, NVTYPE) \ ftype \ cnvlist_get_##type(void *cookiep) \ Modified: head/sys/sys/cnv.h ============================================================================== --- head/sys/sys/cnv.h Thu Oct 26 19:45:15 2017 (r325018) +++ head/sys/sys/cnv.h Thu Oct 26 20:44:42 2017 (r325019) @@ -48,6 +48,12 @@ typedef struct nvlist nvlist_t; __BEGIN_DECLS /* + * Functions which returns information about the given cookie. + */ +const char *cnvlist_name(void *cookiep); +int cnvlist_type(void *cookiep); + +/* * The cnvlist_get functions returns value associated with the given cookie. * If it returns a pointer, the pointer represents internal buffer and should * not be freed by the caller.