From 4558b74377305ae724f4b4862eb2068c79ef00a0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 16 Jul 2015 16:47:24 -0700 Subject: [PATCH] kni: remove needless casts This fixes cases in KNI where kernel allocation function return value is needlessly casted. Detected with coccinelle: lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c:3181:25-28: WARNING: casting value returned by memory allocation function to (u32 *) is useless. lib/librte_eal/linuxapp/kni/kni_vhost.c:690:9-28: WARNING: casting value returned by memory allocation function to (struct rte_kni_fifo *) is useless. lib/librte_eal/linuxapp/kni/kni_vhost.c:684:13-27: WARNING: casting value returned by memory allocation function to (struct sk_buff *) is useless Signed-off-by: Stephen Hemminger --- lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 4 ++-- lib/librte_eal/linuxapp/kni/kni_vhost.c | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c index 47198bb0d3..eed8df6277 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c @@ -3178,8 +3178,8 @@ static int igb_sw_init(struct igb_adapter *adapter) GFP_ATOMIC); /* Setup and initialize a copy of the hw vlan table array */ - adapter->shadow_vfta = (u32 *)kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES, - GFP_ATOMIC); + adapter->shadow_vfta = kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES, + GFP_ATOMIC); #ifdef NO_KNI /* These calls may decrease the number of queues */ if (hw->mac.type < e1000_i210) { diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c index 013a677296..d0c12a6ac4 100644 --- a/lib/librte_eal/linuxapp/kni/kni_vhost.c +++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c @@ -681,14 +681,12 @@ kni_vhost_backend_init(struct kni_dev *kni) } /* cache init */ - q->cache = (struct sk_buff*) - kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff), - GFP_KERNEL); + q->cache = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff), + GFP_KERNEL); if (!q->cache) goto free_fd; - fifo = (struct rte_kni_fifo*) - kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(void *) + fifo = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(void *) + sizeof(struct rte_kni_fifo), GFP_KERNEL); if (!fifo) goto free_cache; -- 2.20.1