Skip to contentSkip to conversation

net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

PATCH Applied Maciej Żenczykowski 2 participants 2 messages Aug 19, 2020

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

PATCH 1/1 net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

From: Maciej Żenczykowski <[email protected]>

This reduces likelihood of incorrect use.

Test: builds

---
 drivers/net/veth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/veth.c +3 -3
index e56cd562a664..b80cbffeb88e 100644
@@ -234,14 +234,14 @@ static bool veth_is_xdp_frame(void *ptr)
 	return (unsigned long)ptr & VETH_XDP_FLAG;
 }
 
-static void *veth_ptr_to_xdp(void *ptr)
+static struct xdp_frame *veth_ptr_to_xdp(void *ptr)
 {
 	return (void *)((unsigned long)ptr & ~VETH_XDP_FLAG);
 }
 
-static void *veth_xdp_to_ptr(void *ptr)
+static void *veth_xdp_to_ptr(struct xdp_frame *xdp)
 {
-	return (void *)((unsigned long)ptr | VETH_XDP_FLAG);
+	return (void *)((unsigned long)xdp | VETH_XDP_FLAG);
 }
 
 static void veth_ptr_free(void *ptr)
Signature · 1 line
2.28.0.220.ged08abb693-goog
#1 lore raw
Quoted 6 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

This reduces likelihood of incorrect use.

Test: builds

I kept this in the commit log though it's a pointless comment. Please reconsider for the future.
If you want to mention how you've tested it, please say so after "---" line.

Quoted 1 line

Applied. Thanks.