Module Name:    src
Committed By:   riastradh
Date:           Thu Aug 20 21:35:24 UTC 2020

Modified Files:
        src/sys/net: if_wg.c

Log Message:
Use container_of rather than casts via void *.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/if_wg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_wg.c
diff -u src/sys/net/if_wg.c:1.15 src/sys/net/if_wg.c:1.16
--- src/sys/net/if_wg.c:1.15	Thu Aug 20 21:35:13 2020
+++ src/sys/net/if_wg.c	Thu Aug 20 21:35:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $	*/
+/*	$NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com>
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3012,7 +3012,7 @@ wg_session_hit_limits(struct wg_session 
 static void
 wg_peer_softint(void *arg)
 {
-	struct wg_peer *wgp = (struct wg_peer *)arg;
+	struct wg_peer *wgp = arg;
 	struct wg_session *wgs;
 	struct mbuf *m;
 	struct psref psref;
@@ -3355,7 +3355,7 @@ wg_clone_create(struct if_clone *ifc, in
 static int
 wg_clone_destroy(struct ifnet *ifp)
 {
-	struct wg_softc *wg = (void *) ifp;
+	struct wg_softc *wg = container_of(ifp, struct wg_softc, wg_if);
 
 	mutex_enter(&wg_softcs.lock);
 	LIST_REMOVE(wg, wg_list);
@@ -3413,7 +3413,7 @@ wg_pick_peer_by_sa(struct wg_softc *wg, 
 
 	WG_TRACE("success");
 
-	wga = (struct wg_allowedip *)rn;
+	wga = container_of(rn, struct wg_allowedip, wga_nodes[0]);
 	wgp = wga->wga_peer;
 	wg_get_peer(wgp, psref);
 

Reply via email to