[PATCH 1/1] cache: assert in nl_cache_mngt_register() for valid oo_keygen() function

Thomas Haller thaller at redhat.com
Mon Nov 24 10:04:50 PST 2014


oo_keygen() requires oo_compare(). Assert in nl_cache_mngt_register().

Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/cache_mngt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c
index 9f8a742..8ed2129 100644
--- a/lib/cache_mngt.c
+++ b/lib/cache_mngt.c
@@ -254,6 +254,9 @@ int nl_cache_mngt_register(struct nl_cache_ops *ops)
 	if (!ops->co_name || !ops->co_obj_ops)
 		return -NLE_INVAL;
 
+	/* oo_keygen() also needs oo_compare() */
+	BUG_ON (ops->co_obj_ops->oo_keygen && !ops->co_obj_ops->oo_compare);
+
 	nl_write_lock(&cache_ops_lock);
 	if (__nl_cache_ops_lookup(ops->co_name)) {
 		nl_write_unlock(&cache_ops_lock);
-- 
1.9.3




More information about the libnl mailing list