From 846a6b3d89aaf4ee2cece0f10148f675c4796841 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 23 Jun 2015 12:10:38 +0200 Subject: sd-netlink: don't treat NULL as root type-system Explicitly export the root type-system to the type-system callers. This avoids treating NULL as root, which for one really looks backwards (NULL is usually a leaf, not root), and secondly prevents us from properly debugging calling into non-nested types. Also rename the root to "type_system_root". Once we support more than rtnl, well will have to revisit that, anyway. --- src/libsystemd/sd-netlink/netlink-types.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/libsystemd/sd-netlink/netlink-types.c') diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index d22194ad71..40548dcbc0 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -476,7 +476,7 @@ static const NLType rtnl_types[RTM_MAX + 1] = { [RTM_GETNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, }; -const NLTypeSystem rtnl_type_system = { +const NLTypeSystem type_system_root = { .count = ELEMENTSOF(rtnl_types), .types = rtnl_types, }; @@ -518,10 +518,7 @@ int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, ui const NLType *nl_type; assert(ret); - - if (!type_system) - type_system = &rtnl_type_system; - + assert(type_system); assert(type_system->types); if (type >= type_system->count) -- cgit v1.2.3-54-g00ecf