* [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
@ 2017-09-18 11:40 Colin King
2017-09-18 12:18 ` David Laight
2017-09-18 23:52 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Colin King @ 2017-09-18 11:40 UTC (permalink / raw)
To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S . Miller, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer tcm is being initialized and is never read, it is only being used
to determine the size of struct tcmsg. Clean this up by removing
variable tcm and explicitly using the sizeof struct tcmsg rather than *tcm.
Cleans up clang warning:
warning: Value stored to 'tcm' during its initialization is never read
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/sched/sch_api.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index c6deb74e3d2f..aa82116ed10c 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1500,7 +1500,6 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
int s_idx, s_q_idx;
struct net_device *dev;
const struct nlmsghdr *nlh = cb->nlh;
- struct tcmsg *tcm = nlmsg_data(nlh);
struct nlattr *tca[TCA_MAX + 1];
int err;
@@ -1510,7 +1509,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
idx = 0;
ASSERT_RTNL();
- err = nlmsg_parse(nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
+ err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, NULL, NULL);
if (err < 0)
return err;
--
2.14.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
2017-09-18 11:40 [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm Colin King
@ 2017-09-18 12:18 ` David Laight
2017-09-18 15:00 ` Eric Dumazet
2017-09-18 23:52 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2017-09-18 12:18 UTC (permalink / raw)
To: 'Colin King', Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S . Miller, netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
From: Colin King
> Sent: 18 September 2017 12:41
> Pointer tcm is being initialized and is never read, it is only being used
> to determine the size of struct tcmsg. Clean this up by removing
> variable tcm and explicitly using the sizeof struct tcmsg rather than *tcm.
> Cleans up clang warning:
>
> warning: Value stored to 'tcm' during its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> net/sched/sch_api.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index c6deb74e3d2f..aa82116ed10c 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -1500,7 +1500,6 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
> int s_idx, s_q_idx;
> struct net_device *dev;
> const struct nlmsghdr *nlh = cb->nlh;
> - struct tcmsg *tcm = nlmsg_data(nlh);
> struct nlattr *tca[TCA_MAX + 1];
> int err;
>
> @@ -1510,7 +1509,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
> idx = 0;
> ASSERT_RTNL();
>
> - err = nlmsg_parse(nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
> + err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, NULL, NULL);
Would sizeof(*nlmsg_data(nlh)) be cleaner??
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
2017-09-18 12:18 ` David Laight
@ 2017-09-18 15:00 ` Eric Dumazet
2017-09-18 15:10 ` David Laight
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2017-09-18 15:00 UTC (permalink / raw)
To: David Laight
Cc: 'Colin King', Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S . Miller, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
On Mon, 2017-09-18 at 12:18 +0000, David Laight wrote:
> From: Colin King
> > Sent: 18 September 2017 12:41
> > Pointer tcm is being initialized and is never read, it is only being used
> > to determine the size of struct tcmsg. Clean this up by removing
> > variable tcm and explicitly using the sizeof struct tcmsg rather than *tcm.
> > Cleans up clang warning:
> >
> > warning: Value stored to 'tcm' during its initialization is never read
> >
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > net/sched/sch_api.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> > index c6deb74e3d2f..aa82116ed10c 100644
> > --- a/net/sched/sch_api.c
> > +++ b/net/sched/sch_api.c
> > @@ -1500,7 +1500,6 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
> > int s_idx, s_q_idx;
> > struct net_device *dev;
> > const struct nlmsghdr *nlh = cb->nlh;
> > - struct tcmsg *tcm = nlmsg_data(nlh);
> > struct nlattr *tca[TCA_MAX + 1];
> > int err;
> >
> > @@ -1510,7 +1509,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
> > idx = 0;
> > ASSERT_RTNL();
> >
> > - err = nlmsg_parse(nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
> > + err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, NULL, NULL);
>
> Would sizeof(*nlmsg_data(nlh)) be cleaner??
Not really, since
static inline void *nlmsg_data(const struct nlmsghdr *nlh)
{
...
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
2017-09-18 15:00 ` Eric Dumazet
@ 2017-09-18 15:10 ` David Laight
0 siblings, 0 replies; 5+ messages in thread
From: David Laight @ 2017-09-18 15:10 UTC (permalink / raw)
To: 'Eric Dumazet'
Cc: 'Colin King', Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S . Miller, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
From: Eric Dumazet
> Sent: 18 September 2017 16:01
...
> > > - err = nlmsg_parse(nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
> > > + err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, NULL, NULL);
> >
> > Would sizeof(*nlmsg_data(nlh)) be cleaner??
>
> Not really, since
>
> static inline void *nlmsg_data(const struct nlmsghdr *nlh)
I thought about that after posting :-(
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
2017-09-18 11:40 [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm Colin King
2017-09-18 12:18 ` David Laight
@ 2017-09-18 23:52 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2017-09-18 23:52 UTC (permalink / raw)
To: colin.king
Cc: jhs, xiyou.wangcong, jiri, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Mon, 18 Sep 2017 12:40:38 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer tcm is being initialized and is never read, it is only being used
> to determine the size of struct tcmsg. Clean this up by removing
> variable tcm and explicitly using the sizeof struct tcmsg rather than *tcm.
> Cleans up clang warning:
>
> warning: Value stored to 'tcm' during its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied to net-next.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-18 23:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18 11:40 [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm Colin King
2017-09-18 12:18 ` David Laight
2017-09-18 15:00 ` Eric Dumazet
2017-09-18 15:10 ` David Laight
2017-09-18 23:52 ` David Miller
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).