* [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c
@ 2016-06-15 22:50 Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 1/2] tc: m_action: Use C99 style initializers for struct req Phil Sutter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Phil Sutter @ 2016-06-15 22:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Found these when doing something else. Shouldn't cause any functional
change.
Changes since v1:
- Replace patch 1/2 with a better solution as suggested by Stephen
Hemminger.
Phil Sutter (2):
tc: m_action: Use C99 style initializers for struct req
tc: m_action: Drop unused variable nladdr in tc_action_gd()
tc/m_action.c | 50 +++++++++++++++++++++++---------------------------
1 file changed, 23 insertions(+), 27 deletions(-)
--
2.8.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [iproute PATCH v2 1/2] tc: m_action: Use C99 style initializers for struct req
2016-06-15 22:50 [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
@ 2016-06-15 22:50 ` Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
2016-06-16 16:42 ` [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2016-06-15 22:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
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>
---
tc/m_action.c | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/tc/m_action.c b/tc/m_action.c
index c416d98a775a6..f97ed2e775012 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -395,18 +395,19 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
struct nlmsghdr n;
struct tcamsg t;
char buf[MAX_MSG];
- } req;
-
- req.t.tca_family = AF_UNSPEC;
-
- memset(&req, 0, sizeof(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 }
+ };
memset(&nladdr, 0, sizeof(nladdr));
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;
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 tcamsg t;
char buf[MAX_MSG];
- } req;
-
- req.t.tca_family = AF_UNSPEC;
-
- memset(&req, 0, sizeof(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.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);
argc -= 1;
argv += 1;
@@ -539,13 +541,11 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
struct nlmsghdr n;
struct tcamsg t;
char buf[MAX_MSG];
- } req;
-
- req.t.tca_family = AF_UNSPEC;
-
- memset(&req, 0, sizeof(req));
-
- req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
+ } req = {
+ .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)),
+ .t.tca_family = AF_UNSPEC,
+ .buf = { 0 }
+ };
tail = NLMSG_TAIL(&req.n);
addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
--
2.8.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [iproute PATCH v2 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd()
2016-06-15 22:50 [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 1/2] tc: m_action: Use C99 style initializers for struct req Phil Sutter
@ 2016-06-15 22:50 ` Phil Sutter
2016-06-16 16:42 ` [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2016-06-15 22:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
This has been there since the introduction of tc/m_action.c back in 2004
and was apparently never in use.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
tc/m_action.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/tc/m_action.c b/tc/m_action.c
index f97ed2e775012..ea16817aefd4f 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -386,7 +386,6 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
int prio = 0;
int ret = 0;
__u32 i;
- struct sockaddr_nl nladdr;
struct rtattr *tail;
struct rtattr *tail2;
struct nlmsghdr *ans = NULL;
@@ -405,9 +404,6 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
.buf = { 0 }
};
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
-
argc -= 1;
argv += 1;
--
2.8.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c
2016-06-15 22:50 [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 1/2] tc: m_action: Use C99 style initializers for struct req Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
@ 2016-06-16 16:42 ` Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2016-06-16 16:42 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
On Thu, 16 Jun 2016 00:50:37 +0200
Phil Sutter <phil@nwl.cc> wrote:
> Found these when doing something else. Shouldn't cause any functional
> change.
>
> Changes since v1:
> - Replace patch 1/2 with a better solution as suggested by Stephen
> Hemminger.
>
> Phil Sutter (2):
> tc: m_action: Use C99 style initializers for struct req
> tc: m_action: Drop unused variable nladdr in tc_action_gd()
>
> tc/m_action.c | 50 +++++++++++++++++++++++---------------------------
> 1 file changed, 23 insertions(+), 27 deletions(-)
>
Applied
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-16 16:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15 22:50 [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 1/2] tc: m_action: Use C99 style initializers for struct req Phil Sutter
2016-06-15 22:50 ` [iproute PATCH v2 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
2016-06-16 16:42 ` [iproute PATCH v2 0/2] Two cosmetic fixes in tc/m_action.c Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).