linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
@ 2014-10-06 21:51 Joe Perches
  2014-10-06 21:56 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Joe Perches @ 2014-10-06 21:51 UTC (permalink / raw)
  To: netdev; +Cc: LKML, John Fastabend

Reduce noise when compiling W=1.

All the variables are unused.
The functions are not called outside of the file so static
is preferred.

Signed-off-by: Joe Perches <joe@perches.com>
---

John, can you please verify that these gen_stats accesses
are unnecessary?  I believe the compiler can elide them in
any case, but I'm not sure what you intended here.

 net/core/dev.c       | 4 ++--
 net/core/gen_stats.c | 4 ----
 net/core/rtnetlink.c | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 1a90530..2049a17 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5239,7 +5239,7 @@ void netdev_upper_dev_unlink(struct net_device *dev,
 }
 EXPORT_SYMBOL(netdev_upper_dev_unlink);
 
-void netdev_adjacent_add_links(struct net_device *dev)
+static void netdev_adjacent_add_links(struct net_device *dev)
 {
 	struct netdev_adjacent *iter;
 
@@ -5264,7 +5264,7 @@ void netdev_adjacent_add_links(struct net_device *dev)
 	}
 }
 
-void netdev_adjacent_del_links(struct net_device *dev)
+static void netdev_adjacent_del_links(struct net_device *dev)
 {
 	struct netdev_adjacent *iter;
 
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 14681b9..01be9cf 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -106,13 +106,9 @@ __gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
 	for_each_possible_cpu(i) {
 		struct gnet_stats_basic_cpu *bcpu = per_cpu_ptr(cpu, i);
 		unsigned int start;
-		__u64 bytes;
-		__u32 packets;
 
 		do {
 			start = u64_stats_fetch_begin_irq(&bcpu->syncp);
-			bytes = bcpu->bstats.bytes;
-			packets = bcpu->bstats.packets;
 		} while (u64_stats_fetch_retry_irq(&bcpu->syncp, start));
 
 		bstats->bytes += bcpu->bstats.bytes;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a688268..c2fe350 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2917,7 +2917,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	struct net *net = sock_net(skb->sk);
 	rtnl_doit_func doit;
-	int sz_idx, kind;
+	int kind;
 	int family;
 	int type;
 	int err;
@@ -2933,7 +2933,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 		return 0;
 
 	family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
-	sz_idx = type>>2;
 	kind = type&3;
 
 	if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 21:51 [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions Joe Perches
@ 2014-10-06 21:56 ` David Miller
  2014-10-06 22:04   ` Joe Perches
  2014-10-06 22:02 ` Eric Dumazet
  2014-10-06 22:12 ` Cong Wang
  2 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2014-10-06 21:56 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel, john.fastabend

From: Joe Perches <joe@perches.com>
Date: Mon, 06 Oct 2014 14:51:38 -0700

> Reduce noise when compiling W=1.
> 
> All the variables are unused.
> The functions are not called outside of the file so static
> is preferred.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> 
> John, can you please verify that these gen_stats accesses
> are unnecessary?  I believe the compiler can elide them in
> any case, but I'm not sure what you intended here.

BTW, this patch reminds me that if people think there are
subdirectories where we can turn on things like -Werror in the
networking I would be very happy to apply such patches.

Things like arch/sparc has had this for years, I even forget when I
added it. :-)

Things like net/core/ for example should be doable for sure.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 21:51 [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions Joe Perches
  2014-10-06 21:56 ` David Miller
@ 2014-10-06 22:02 ` Eric Dumazet
  2014-10-06 22:12 ` Cong Wang
  2 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2014-10-06 22:02 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, LKML, John Fastabend

On Mon, 2014-10-06 at 14:51 -0700, Joe Perches wrote:
> Reduce noise when compiling W=1.
> 
> All the variables are unused.
> The functions are not called outside of the file so static
> is preferred.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> 
> John, can you please verify that these gen_stats accesses
> are unnecessary?  I believe the compiler can elide them in
> any case, but I'm not sure what you intended here.

...

> diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
> index 14681b9..01be9cf 100644
> --- a/net/core/gen_stats.c
> +++ b/net/core/gen_stats.c
> @@ -106,13 +106,9 @@ __gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
>  	for_each_possible_cpu(i) {
>  		struct gnet_stats_basic_cpu *bcpu = per_cpu_ptr(cpu, i);
>  		unsigned int start;
> -		__u64 bytes;
> -		__u32 packets;
>  
>  		do {
>  			start = u64_stats_fetch_begin_irq(&bcpu->syncp);
> -			bytes = bcpu->bstats.bytes;
> -			packets = bcpu->bstats.packets;
>  		} while (u64_stats_fetch_retry_irq(&bcpu->syncp, start));
>  

Well... Please fix the bug for real.





>  		bstats->bytes += bcpu->bstats.bytes;

->

	bstats->bytes += bytes;
	bstats->packets += packets;




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 21:56 ` David Miller
@ 2014-10-06 22:04   ` Joe Perches
  2014-10-06 22:19     ` David Miller
  2014-10-06 22:27     ` josh
  0 siblings, 2 replies; 7+ messages in thread
From: Joe Perches @ 2014-10-06 22:04 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, john.fastabend

On Mon, 2014-10-06 at 17:56 -0400, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Mon, 06 Oct 2014 14:51:38 -0700
> 
> > Reduce noise when compiling W=1.
[]
> BTW, this patch reminds me that if people think there are
> subdirectories where we can turn on things like -Werror in the
> networking I would be very happy to apply such patches.
[]
> Things like net/core/ for example should be doable for sure.

I don't have any significant opposition to -Werror, but
I think there are real arguments _against_ using -Werror.

I think the primary one is new compiler versions have a
tendency to add new warnings for various things that can
unnecessarily and unpredictably break the build.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 21:51 [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions Joe Perches
  2014-10-06 21:56 ` David Miller
  2014-10-06 22:02 ` Eric Dumazet
@ 2014-10-06 22:12 ` Cong Wang
  2 siblings, 0 replies; 7+ messages in thread
From: Cong Wang @ 2014-10-06 22:12 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, LKML, John Fastabend

On Mon, Oct 6, 2014 at 2:51 PM, Joe Perches <joe@perches.com> wrote:
> John, can you please verify that these gen_stats accesses
> are unnecessary?  I believe the compiler can elide them in
> any case, but I'm not sure what you intended here.
>
>  net/core/dev.c       | 4 ++--
>  net/core/gen_stats.c | 4 ----
>  net/core/rtnetlink.c | 3 +--
>  3 files changed, 3 insertions(+), 8 deletions(-)

You need to split this patch.


> diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
> index 14681b9..01be9cf 100644
> --- a/net/core/gen_stats.c
> +++ b/net/core/gen_stats.c
> @@ -106,13 +106,9 @@ __gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
>         for_each_possible_cpu(i) {
>                 struct gnet_stats_basic_cpu *bcpu = per_cpu_ptr(cpu, i);
>                 unsigned int start;
> -               __u64 bytes;
> -               __u32 packets;
>
>                 do {
>                         start = u64_stats_fetch_begin_irq(&bcpu->syncp);
> -                       bytes = bcpu->bstats.bytes;
> -                       packets = bcpu->bstats.packets;
>                 } while (u64_stats_fetch_retry_irq(&bcpu->syncp, start));


Looks like we really need them:

diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 14681b9..7948ecf 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -115,8 +115,8 @@ __gnet_stats_copy_basic_cpu(struct
gnet_stats_basic_packed *bstats,
                        packets = bcpu->bstats.packets;
                } while (u64_stats_fetch_retry_irq(&bcpu->syncp, start));

-               bstats->bytes += bcpu->bstats.bytes;
-               bstats->packets += bcpu->bstats.packets;
+               bstats->bytes += bytes;
+               bstats->packets += packets;
        }
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 22:04   ` Joe Perches
@ 2014-10-06 22:19     ` David Miller
  2014-10-06 22:27     ` josh
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2014-10-06 22:19 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel, john.fastabend

From: Joe Perches <joe@perches.com>
Date: Mon, 06 Oct 2014 15:04:24 -0700

> On Mon, 2014-10-06 at 17:56 -0400, David Miller wrote:
>> From: Joe Perches <joe@perches.com>
>> Date: Mon, 06 Oct 2014 14:51:38 -0700
>> 
>> > Reduce noise when compiling W=1.
> []
>> BTW, this patch reminds me that if people think there are
>> subdirectories where we can turn on things like -Werror in the
>> networking I would be very happy to apply such patches.
> []
>> Things like net/core/ for example should be doable for sure.
> 
> I don't have any significant opposition to -Werror, but
> I think there are real arguments _against_ using -Werror.
> 
> I think the primary one is new compiler versions have a
> tendency to add new warnings for various things that can
> unnecessarily and unpredictably break the build.

My experience over at least a decade with arch/sparc doesn't match
your claims.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions
  2014-10-06 22:04   ` Joe Perches
  2014-10-06 22:19     ` David Miller
@ 2014-10-06 22:27     ` josh
  1 sibling, 0 replies; 7+ messages in thread
From: josh @ 2014-10-06 22:27 UTC (permalink / raw)
  To: Joe Perches; +Cc: David Miller, netdev, linux-kernel, john.fastabend

On Mon, Oct 06, 2014 at 03:04:24PM -0700, Joe Perches wrote:
> On Mon, 2014-10-06 at 17:56 -0400, David Miller wrote:
> > From: Joe Perches <joe@perches.com>
> > Date: Mon, 06 Oct 2014 14:51:38 -0700
> > 
> > > Reduce noise when compiling W=1.
> []
> > BTW, this patch reminds me that if people think there are
> > subdirectories where we can turn on things like -Werror in the
> > networking I would be very happy to apply such patches.
> []
> > Things like net/core/ for example should be doable for sure.
> 
> I don't have any significant opposition to -Werror, but
> I think there are real arguments _against_ using -Werror.
> 
> I think the primary one is new compiler versions have a
> tendency to add new warnings for various things that can
> unnecessarily and unpredictably break the build.

-Werror is a bad idea, even on a per-directory basis.  However,
-Werror=specific-warning is a great idea.  We should add that for
high-value warnings that have been entirely eliminated in a directory.

- Josh Triplett

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-10-06 22:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 21:51 [PATCH net-next] net: core: Quiet W=1 warnings for unused vars and static functions Joe Perches
2014-10-06 21:56 ` David Miller
2014-10-06 22:04   ` Joe Perches
2014-10-06 22:19     ` David Miller
2014-10-06 22:27     ` josh
2014-10-06 22:02 ` Eric Dumazet
2014-10-06 22:12 ` Cong Wang

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).