1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

sd-netlink: make type_get_type_system{,_union}() return value directly

This commit is contained in:
Yu Watanabe 2021-07-04 14:33:02 +09:00
parent c737abd31b
commit 49eb0a6889
5 changed files with 13 additions and 24 deletions

View File

@ -53,7 +53,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nl
m->hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
type_get_type_system(genl_cmd_type, &type_system);
type_system = type_get_type_system(genl_cmd_type);
r = type_system_get_type(type_system, &nl_type, cmd);
if (r < 0)
@ -62,7 +62,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nl
m->hdr->nlmsg_len = size;
m->hdr->nlmsg_type = nlmsg_type;
type_get_type_system(nl_type, &m->containers[0].type_system);
m->containers[0].type_system = type_get_type_system(nl_type);
*(struct genlmsghdr *) NLMSG_DATA(m->hdr) = (struct genlmsghdr) {
.cmd = cmd,

View File

@ -71,7 +71,7 @@ int message_new(sd_netlink *nl, sd_netlink_message **ret, uint16_t type) {
m->hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
type_get_type_system(nl_type, &m->containers[0].type_system);
m->containers[0].type_system = type_get_type_system(nl_type);
m->hdr->nlmsg_len = size;
m->hdr->nlmsg_type = type;
@ -1328,11 +1328,7 @@ int sd_netlink_message_rewind(sd_netlink_message *m, sd_netlink *genl) {
size = type_get_size(nl_type);
if (type == NETLINK_TYPE_NESTED) {
const NLTypeSystem *type_system;
type_get_type_system(nl_type, &type_system);
m->containers[0].type_system = type_system;
m->containers[0].type_system = type_get_type_system(nl_type);
if (sd_netlink_message_is_error(m))
r = netlink_message_parse_error(m);

View File

@ -1700,22 +1700,18 @@ size_t type_get_size(const NLType *type) {
return type->size;
}
void type_get_type_system(const NLType *nl_type, const NLTypeSystem **ret) {
const NLTypeSystem *type_get_type_system(const NLType *nl_type) {
assert(nl_type);
assert(ret);
assert(nl_type->type == NETLINK_TYPE_NESTED);
assert(nl_type->type_system);
*ret = nl_type->type_system;
return nl_type->type_system;
}
void type_get_type_system_union(const NLType *nl_type, const NLTypeSystemUnion **ret) {
const NLTypeSystemUnion *type_get_type_system_union(const NLType *nl_type) {
assert(nl_type);
assert(ret);
assert(nl_type->type == NETLINK_TYPE_UNION);
assert(nl_type->type_system_union);
*ret = nl_type->type_system_union;
return nl_type->type_system_union;
}
uint16_t type_system_get_count(const NLTypeSystem *type_system) {
@ -1778,7 +1774,6 @@ int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, ui
return -EOPNOTSUPP;
*ret = nl_type;
return 0;
}
@ -1792,7 +1787,7 @@ int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSys
if (r < 0)
return r;
type_get_type_system(nl_type, ret);
*ret = type_get_type_system(nl_type);
return 0;
}
@ -1806,7 +1801,7 @@ int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLT
if (r < 0)
return r;
type_get_type_system_union(nl_type, ret);
*ret = type_get_type_system_union(nl_type);
return 0;
}
@ -1827,7 +1822,6 @@ int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union
assert(type < type_system_union->num);
*ret = &type_system_union->type_systems[type];
return 0;
}
@ -1847,6 +1841,5 @@ int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_sys
return -EOPNOTSUPP;
*ret = type_system;
return 0;
}

View File

@ -47,8 +47,8 @@ extern const NLTypeSystem genl_family_type_system_root;
uint16_t type_get_type(const NLType *type);
size_t type_get_size(const NLType *type);
void type_get_type_system(const NLType *type, const NLTypeSystem **ret);
void type_get_type_system_union(const NLType *type, const NLTypeSystemUnion **ret);
const NLTypeSystem *type_get_type_system(const NLType *type);
const NLTypeSystemUnion *type_get_type_system_union(const NLType *type);
const NLTypeSystem* type_system_get_root(int protocol);
uint16_t type_system_get_count(const NLTypeSystem *type_system);

View File

@ -43,7 +43,7 @@ static int nft_message_new(sd_netlink *nfnl, sd_netlink_message **ret, int famil
m->hdr->nlmsg_flags = NLM_F_REQUEST | flags;
type_get_type_system(nl_type, &m->containers[0].type_system);
m->containers[0].type_system = type_get_type_system(nl_type);
r = type_system_get_type_system(m->containers[0].type_system,
&m->containers[0].type_system,