Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Oct 2017 20:44:42 +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: r325019 - in head: share/man/man9 sys/contrib/libnv sys/sys
Message-ID:  <201710262044.v9QKigHZ055658@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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.



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