* [iproute PATCH 0/2] Two cosmetic fixes in tc/m_action.c
@ 2016-06-14 22:26 Phil Sutter
2016-06-14 22:26 ` [iproute PATCH 1/2] tc: m_action: Fix for field init before memset Phil Sutter
2016-06-14 22:26 ` [iproute PATCH 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
0 siblings, 2 replies; 4+ messages in thread
From: Phil Sutter @ 2016-06-14 22:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Found these when doing something else. Shouldn't cause any functional
change.
Phil Sutter (2):
tc: m_action: Fix for field init before memset
tc: m_action: Drop unused variable nladdr in tc_action_gd()
tc/m_action.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
--
2.8.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [iproute PATCH 1/2] tc: m_action: Fix for field init before memset
2016-06-14 22:26 [iproute PATCH 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
@ 2016-06-14 22:26 ` Phil Sutter
2016-06-14 23:51 ` Stephen Hemminger
2016-06-14 22:26 ` [iproute PATCH 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
1 sibling, 1 reply; 4+ messages in thread
From: Phil Sutter @ 2016-06-14 22:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Phil Sutter
From: Phil Sutter <psutter@redhat.com>
Initializing req.t.tca_family before setting the whole req object to
zero using memset does not make sense. Instead initialize the field
after calling memset.
Note that this change has no functional effect since AF_UNSPEC is
defined to 0 anyway, so this fix is a purely cosmetic one.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
tc/m_action.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/tc/m_action.c b/tc/m_action.c
index c416d98a775a6..1b34370f4ec09 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -397,9 +397,8 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
char buf[MAX_MSG];
} req;
- req.t.tca_family = AF_UNSPEC;
-
memset(&req, 0, sizeof(req));
+ req.t.tca_family = AF_UNSPEC;
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
@@ -502,10 +501,8 @@ static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***ar
char buf[MAX_MSG];
} req;
- req.t.tca_family = AF_UNSPEC;
-
memset(&req, 0, sizeof(req));
-
+ req.t.tca_family = AF_UNSPEC;
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
req.n.nlmsg_flags = NLM_F_REQUEST|flags;
req.n.nlmsg_type = cmd;
@@ -541,10 +538,8 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
char buf[MAX_MSG];
} req;
- req.t.tca_family = AF_UNSPEC;
-
memset(&req, 0, sizeof(req));
-
+ req.t.tca_family = AF_UNSPEC;
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
tail = NLMSG_TAIL(&req.n);
--
2.8.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [iproute PATCH 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd()
2016-06-14 22:26 [iproute PATCH 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
2016-06-14 22:26 ` [iproute PATCH 1/2] tc: m_action: Fix for field init before memset Phil Sutter
@ 2016-06-14 22:26 ` Phil Sutter
1 sibling, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2016-06-14 22:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Phil Sutter
From: Phil Sutter <psutter@redhat.com>
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 1b34370f4ec09..fd324090db1f2 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;
@@ -400,9 +399,6 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
memset(&req, 0, sizeof(req));
req.t.tca_family = AF_UNSPEC;
- 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;
--
2.8.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [iproute PATCH 1/2] tc: m_action: Fix for field init before memset
2016-06-14 22:26 ` [iproute PATCH 1/2] tc: m_action: Fix for field init before memset Phil Sutter
@ 2016-06-14 23:51 ` Stephen Hemminger
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2016-06-14 23:51 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev, Phil Sutter
On Wed, 15 Jun 2016 00:26:08 +0200
Phil Sutter <phil@nwl.cc> wrote:
> From: Phil Sutter <psutter@redhat.com>
>
> Initializing req.t.tca_family before setting the whole req object to
> zero using memset does not make sense. Instead initialize the field
> after calling memset.
>
> Note that this change has no functional effect since AF_UNSPEC is
> defined to 0 anyway, so this fix is a purely cosmetic one.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
Instead of moving around the code with memset(), it would make more
sense to change this and other places to use C99 style initializers.
They are safer and the code is cleaner.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-14 23:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-14 22:26 [iproute PATCH 0/2] Two cosmetic fixes in tc/m_action.c Phil Sutter
2016-06-14 22:26 ` [iproute PATCH 1/2] tc: m_action: Fix for field init before memset Phil Sutter
2016-06-14 23:51 ` Stephen Hemminger
2016-06-14 22:26 ` [iproute PATCH 2/2] tc: m_action: Drop unused variable nladdr in tc_action_gd() Phil Sutter
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).