Skip to contentSkip to conversation

af_packet: fix sparse warning

PATCH Applied Michael S. Tsirkin 2 participants 2 messages Nov 24, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 af_packet: fix sparse warning

af_packet produces lots of these:
net/packet/af_packet.c:384:39: warning: incorrect type in return expression (different modifiers)
net/packet/af_packet.c:384:39: expected struct page [pure] *
net/packet/af_packet.c:384:39: got struct page *

this seems to be because sparse does not realize that _pure refers to function, not the returned pointer.

Tweak code slightly to avoid the warning.

---
 net/packet/af_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
index d4a877e..586229a 100644
@@ -378,7 +378,7 @@ static void unregister_prot_hook(struct sock *sk, bool sync)
 		__unregister_prot_hook(sk, sync);
 }
 
-static inline __pure struct page *pgv_to_page(void *addr)
+static inline struct page * __pure pgv_to_page(void *addr)
 {
 	if (is_vmalloc_addr(addr))
 		return vmalloc_to_page(addr);
Signature · 1 line
MST
maintainer Applied
#1 lore raw

From: "Michael S. Tsirkin" <[email protected]>
Date: Mon, 24 Nov 2014 13:32:16 +0200

Quoted 11 lines

af_packet produces lots of these:
net/packet/af_packet.c:384:39: warning: incorrect type in return expression (different modifiers)
net/packet/af_packet.c:384:39: expected struct page [pure] *
net/packet/af_packet.c:384:39: got struct page *

this seems to be because sparse does not realize that _pure refers to function, not the returned pointer.

Tweak code slightly to avoid the warning.

Applied, please report the sparse bug if you haven't already.

Thanks.