mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-08-14 13:17:42 +00:00
tc: m_action: Use C99 style initializers for struct req
Instead of initializing fields after (or sometimes even before) zeroing the whole struct via memset(), initialize the whole thing at declaration time. Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
parent
9b32f89693
commit
a0a73b298a
@ -395,18 +395,19 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
|
|||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
struct tcamsg t;
|
struct tcamsg t;
|
||||||
char buf[MAX_MSG];
|
char buf[MAX_MSG];
|
||||||
} req;
|
} req = {
|
||||||
|
.n = {
|
||||||
req.t.tca_family = AF_UNSPEC;
|
.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)),
|
||||||
|
.nlmsg_flags = NLM_F_REQUEST | flags,
|
||||||
memset(&req, 0, sizeof(req));
|
.nlmsg_type = cmd,
|
||||||
|
},
|
||||||
|
.t.tca_family = AF_UNSPEC,
|
||||||
|
.buf = { 0 }
|
||||||
|
};
|
||||||
|
|
||||||
memset(&nladdr, 0, sizeof(nladdr));
|
memset(&nladdr, 0, sizeof(nladdr));
|
||||||
nladdr.nl_family = AF_NETLINK;
|
nladdr.nl_family = AF_NETLINK;
|
||||||
|
|
||||||
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
|
|
||||||
req.n.nlmsg_flags = NLM_F_REQUEST|flags;
|
|
||||||
req.n.nlmsg_type = cmd;
|
|
||||||
argc -= 1;
|
argc -= 1;
|
||||||
argv += 1;
|
argv += 1;
|
||||||
|
|
||||||
@ -500,15 +501,16 @@ static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***ar
|
|||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
struct tcamsg t;
|
struct tcamsg t;
|
||||||
char buf[MAX_MSG];
|
char buf[MAX_MSG];
|
||||||
} req;
|
} req = {
|
||||||
|
.n = {
|
||||||
|
.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)),
|
||||||
|
.nlmsg_flags = NLM_F_REQUEST | flags,
|
||||||
|
.nlmsg_type = cmd,
|
||||||
|
},
|
||||||
|
.t.tca_family = AF_UNSPEC,
|
||||||
|
.buf = { 0 }
|
||||||
|
};
|
||||||
|
|
||||||
req.t.tca_family = AF_UNSPEC;
|
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
|
||||||
|
|
||||||
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
|
|
||||||
req.n.nlmsg_flags = NLM_F_REQUEST|flags;
|
|
||||||
req.n.nlmsg_type = cmd;
|
|
||||||
tail = NLMSG_TAIL(&req.n);
|
tail = NLMSG_TAIL(&req.n);
|
||||||
argc -= 1;
|
argc -= 1;
|
||||||
argv += 1;
|
argv += 1;
|
||||||
@ -539,13 +541,11 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
|
|||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
struct tcamsg t;
|
struct tcamsg t;
|
||||||
char buf[MAX_MSG];
|
char buf[MAX_MSG];
|
||||||
} req;
|
} req = {
|
||||||
|
.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)),
|
||||||
req.t.tca_family = AF_UNSPEC;
|
.t.tca_family = AF_UNSPEC,
|
||||||
|
.buf = { 0 }
|
||||||
memset(&req, 0, sizeof(req));
|
};
|
||||||
|
|
||||||
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
|
|
||||||
|
|
||||||
tail = NLMSG_TAIL(&req.n);
|
tail = NLMSG_TAIL(&req.n);
|
||||||
addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
|
addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user