Skip to content

Commit 7b5c2ef

Browse files
sheldnwukuba-moo
authored andcommitted
ynl-gen-cpp: add support for generating nlctrl
Summary: Enable nlctrl code generation. and fix compile error ynl_attr_data() return void* type which could not be implicitly cast to const struct nlattr* in C++. add explicit cast in code generation Test Plan: make sure code could be generated and compiled Signed-off-by: Sheldon Wu <xzw2048@gmail.com>
1 parent ae9981f commit 7b5c2ef

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

generated/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GENS_PATHS=$(shell grep -nrI --files-without-match \
1717
'protocol: netlink' ../Documentation/netlink/specs/)
1818
GENS_PATHS+=$(wildcard ../Documentation/netlink/specs/rt-*.yaml)
1919
GENS_ALL=$(patsubst ../Documentation/netlink/specs/%.yaml,%,${GENS_PATHS})
20-
GENS=$(filter-out nlctrl,${GENS_ALL})
20+
GENS=$(filter-out ,${GENS_ALL})
2121
SRCS=$(patsubst %,%-user.cpp,${GENS})
2222
HDRS=$(patsubst %,%-user.hpp,${GENS})
2323
OBJS=$(patsubst %,%-user.cpp.o,${GENS})

generated/nlctrl-user.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ int nlctrl_getpolicy_rsp_parse(const struct nlmsghdr *nlh,
522522

523523
parg.rsp_policy = &nlctrl_op_policy_attrs_nest;
524524
parg.data = &dst->op_policy.emplace();
525-
attr_op_id = ynl_attr_data(attr);
525+
attr_op_id = (const struct nlattr*)ynl_attr_data(attr);
526526
op_id = ynl_attr_type(attr_op_id);
527527
nlctrl_op_policy_attrs_parse(&parg, attr_op_id, op_id);
528528
} else if (type == CTRL_ATTR_POLICY) {
@@ -535,9 +535,9 @@ int nlctrl_getpolicy_rsp_parse(const struct nlmsghdr *nlh,
535535

536536
parg.rsp_policy = &nlctrl_policy_attrs_nest;
537537
parg.data = &dst->policy.emplace();
538-
attr_policy_id = ynl_attr_data(attr);
538+
attr_policy_id = (const struct nlattr*)ynl_attr_data(attr);
539539
policy_id = ynl_attr_type(attr_policy_id);
540-
attr_attr_id = ynl_attr_data(attr_policy_id);
540+
attr_attr_id = (const struct nlattr*)ynl_attr_data(attr_policy_id);
541541
attr_id = ynl_attr_type(attr_attr_id);
542542
nlctrl_policy_attrs_parse(&parg, attr_attr_id, policy_id, attr_id);
543543
}

ynl-gen-cpp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def _attr_get(self, ri, var):
813813
local_vars += [f'__u32 {", ".join(tv_names)};']
814814
for level in self.attr["type-value"]:
815815
level = c_lower(level)
816-
get_lines += [f"attr_{level} = ynl_attr_data({prev});"]
816+
get_lines += [f"attr_{level} = (const struct nlattr*)ynl_attr_data({prev});"]
817817
get_lines += [f"{level} = ynl_attr_type(attr_{level});"]
818818
prev = "attr_" + level
819819

0 commit comments

Comments
 (0)