Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1734067 > unrolled thread

[PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

Started byColin King <colin.king@canonical.com>
First post2017-09-18 13:50 +0200
Last post2017-09-19 02:00 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm Colin King <colin.king@canonical.com> - 2017-09-18 13:50 +0200
    RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove  need to declare tcm David Laight <David.Laight@ACULAB.COM> - 2017-09-18 14:20 +0200
      Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove  need to declare tcm Eric Dumazet <eric.dumazet@gmail.com> - 2017-09-18 17:10 +0200
        RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove  need to declare tcm David Laight <David.Laight@ACULAB.COM> - 2017-09-18 17:20 +0200
    Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove  need to declare tcm David Miller <davem@davemloft.net> - 2017-09-19 02:00 +0200

#1734067 — [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

FromColin King <colin.king@canonical.com>
Date2017-09-18 13:50 +0200
Subject[PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
Message-ID<ur2IO-5LK-3@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1734079 — RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

FromDavid Laight <David.Laight@ACULAB.COM>
Date2017-09-18 14:20 +0200
SubjectRE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
Message-ID<ur3bP-6bT-1@gated-at.bofh.it>
In reply to#1734067
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

[toc] | [prev] | [next] | [standalone]


#1734212 — Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

FromEric Dumazet <eric.dumazet@gmail.com>
Date2017-09-18 17:10 +0200
SubjectRe: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
Message-ID<ur5Qm-7VK-23@gated-at.bofh.it>
In reply to#1734079
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)
{
...
}

[toc] | [prev] | [next] | [standalone]


#1734220 — RE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

FromDavid Laight <David.Laight@ACULAB.COM>
Date2017-09-18 17:20 +0200
SubjectRE: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
Message-ID<ur603-7Z6-39@gated-at.bofh.it>
In reply to#1734212
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

[toc] | [prev] | [next] | [standalone]


#1734550 — Re: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm

FromDavid Miller <davem@davemloft.net>
Date2017-09-19 02:00 +0200
SubjectRe: [PATCH] net_sched: use explicit size of struct tcmsg, remove need to declare tcm
Message-ID<ure7g-4Xi-3@gated-at.bofh.it>
In reply to#1734067
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web