From 31b574ef99a79fb654085693423f48a3bf0e7f81 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 22 Jun 2020 12:58:01 -0700 Subject: device: remove some unnecessary unsafe Signed-off-by: Brad Fitzpatrick --- device/indextable.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'device') 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() { -- cgit v1.2.3