[PATCH] igmp: fix build warning

From: Sudip Mukherjee
Date: Tue Feb 16 2016 - 03:22:44 EST


We were getting build warnings about:
net/ipv4/igmp.c: In function âigmp_group_addedâ:
net/ipv4/igmp.c:1227:14: warning: unused variable ânetâ [-Wunused-variable]

net/ipv4/igmp.c: In function âip_mc_inc_groupâ:
net/ipv4/igmp.c:1319:14: warning: unused variable ânetâ [-Wunused-variable]

net/ipv4/igmp.c: In function âip_mc_init_devâ:
net/ipv4/igmp.c:1646:14: warning: unused variable ânetâ [-Wunused-variable]

net/ipv4/igmp.c: In function âip_mc_upâ:
net/ipv4/igmp.c:1665:14: warning: unused variable ânetâ [-Wunused-variable]

These variables are only used when CONFIG_IP_MULTICAST is defined. Mark
them as '__maybe_unused'.

Signed-off-by: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>
---
net/ipv4/igmp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7c95335..0ba241b 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1224,7 +1224,7 @@ static void igmp_group_dropped(struct ip_mc_list *im)
static void igmp_group_added(struct ip_mc_list *im)
{
struct in_device *in_dev = im->interface;
- struct net *net = dev_net(in_dev->dev);
+ struct net __maybe_unused *net = dev_net(in_dev->dev);

if (im->loaded == 0) {
im->loaded = 1;
@@ -1316,7 +1316,7 @@ static void ip_mc_hash_remove(struct in_device *in_dev,
void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
{
struct ip_mc_list *im;
- struct net *net = dev_net(in_dev->dev);
+ struct net __maybe_unused *net = dev_net(in_dev->dev);

ASSERT_RTNL();

@@ -1643,7 +1643,7 @@ void ip_mc_down(struct in_device *in_dev)

void ip_mc_init_dev(struct in_device *in_dev)
{
- struct net *net = dev_net(in_dev->dev);
+ struct net __maybe_unused *net = dev_net(in_dev->dev);
ASSERT_RTNL();

#ifdef CONFIG_IP_MULTICAST
@@ -1662,7 +1662,7 @@ void ip_mc_init_dev(struct in_device *in_dev)
void ip_mc_up(struct in_device *in_dev)
{
struct ip_mc_list *pmc;
- struct net *net = dev_net(in_dev->dev);
+ struct net __maybe_unused *net = dev_net(in_dev->dev);

ASSERT_RTNL();

--
1.9.1