aboutsummaryrefslogtreecommitdiffstats
path: root/tun_darwin.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-22 18:33:50 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-22 18:35:52 +0200
commitb4cef2524f3b2be11f905c4114e2e747a8101160 (patch)
tree3bd95e4ce54c72edc8cbf5d0eb9cf7202048bebd /tun_darwin.go
parentBump dependencies for OpenBSD (diff)
downloadwireguard-go-b4cef2524f3b2be11f905c4114e2e747a8101160.tar.xz
wireguard-go-b4cef2524f3b2be11f905c4114e2e747a8101160.zip
Fix integer conversions
Diffstat (limited to '')
-rw-r--r--tun_darwin.go8
1 files changed, 1 insertions, 7 deletions
diff --git a/tun_darwin.go b/tun_darwin.go
index 8e4b970..e5a01a7 100644
--- a/tun_darwin.go
+++ b/tun_darwin.go
@@ -380,11 +380,5 @@ func (tun *NativeTun) MTU() (int, error) {
return 0, fmt.Errorf("failed to get MTU on %s", tun.name)
}
- // convert result to signed 32-bit int
-
- val := binary.LittleEndian.Uint32(ifr[16:20])
- if val >= (1 << 31) {
- return int(val-(1<<31)) - (1 << 31), nil
- }
- return int(val), nil
+ return int(*(*int32)(unsafe.Pointer(&ifr[16]))), nil
}