diff options
author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2020-06-22 12:58:01 -0700 |
---|---|---|
committer | David Crawshaw <crawshaw@tailscale.com> | 2020-07-15 06:59:44 +1000 |
commit | 31b574ef99a79fb654085693423f48a3bf0e7f81 (patch) | |
tree | 5d6a9ac28d54e113758431d5a10d5306e6e5c0f0 /device | |
parent | 3c41141fb47781f5c7526662ef057c2aa3d71757 (diff) |
device: remove some unnecessary unsafe
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'device')
-rw-r--r-- | device/indextable.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/device/indextable.go b/device/indextable.go index 5e10eef..d2dc8a7 100644 --- a/device/indextable.go +++ b/device/indextable.go @@ -7,8 +7,8 @@ package device import ( "crypto/rand" + "encoding/binary" "sync" - "unsafe" ) type IndexTableEntry struct { @@ -25,7 +25,8 @@ type IndexTable struct { func randUint32() (uint32, error) { var integer [4]byte _, err := rand.Read(integer[:]) - return *(*uint32)(unsafe.Pointer(&integer[0])), err + // Arbitrary endianness; both are intrinsified by the Go compiler. + return binary.LittleEndian.Uint32(integer[:]), err } func (table *IndexTable) Init() { |