diff mbox

[dpdk-dev] kni: fix unused variable compile error

Message ID 20161014112440.12966-1-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Ferruh Yigit Oct. 14, 2016, 11:24 a.m. UTC
compile error:
  CC [M]  .../lib/librte_eal/linuxapp/kni/kni_misc.o
cc1: warnings being treated as errors
.../lib/librte_eal/linuxapp/kni/kni_misc.c: In function ‘kni_exit_net’:
.../lib/librte_eal/linuxapp/kni/kni_misc.c:113:18:
error: unused variable ‘knet’

For some kernel versions mutex_destroy() is macro and does nothing,
this cause an unused variable warning for knet which used in mutex_destroy

Added unused attribute to the knet variable.

Fixes: 93a298b34e1b ("kni: support core id parameter in single threaded mode")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Thomas Monjalon Oct. 14, 2016, 12:30 p.m. UTC | #1
2016-10-14 12:24, Ferruh Yigit:
> compile error:
>   CC [M]  .../lib/librte_eal/linuxapp/kni/kni_misc.o
> cc1: warnings being treated as errors
> .../lib/librte_eal/linuxapp/kni/kni_misc.c: In function ‘kni_exit_net’:
> .../lib/librte_eal/linuxapp/kni/kni_misc.c:113:18:
> error: unused variable ‘knet’
> 
> For some kernel versions mutex_destroy() is macro and does nothing,
> this cause an unused variable warning for knet which used in mutex_destroy
> 
> Added unused attribute to the knet variable.
> 
> Fixes: 93a298b34e1b ("kni: support core id parameter in single threaded mode")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

That's why supporting an out-of-tree kernel module is a nightmare.
Compilation breaks everytime with various kernels :(

Please could you tell which Linux versions are affected?
diff mbox

Patch

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 3303d9b..497db9b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -110,9 +110,11 @@  kni_init_net(struct net *net)
 static void __net_exit
 kni_exit_net(struct net *net)
 {
-	struct kni_net *knet = net_generic(net, kni_net_id);
+	struct kni_net *knet __maybe_unused;
 
+	knet = net_generic(net, kni_net_id);
 	mutex_destroy(&knet->kni_kthread_lock);
+
 #ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS
 	kfree(knet);
 #endif