From be644b36fe175131fe65de032c7b98af20248617 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 15 Jan 2023 18:38:35 +0100 Subject: [PATCH] lorawan: simplify GetRand16() function Signed-off-by: deadprogram --- lora/lorawan/bytes.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lora/lorawan/bytes.go b/lora/lorawan/bytes.go index e7e7d29..af110c2 100644 --- a/lora/lorawan/bytes.go +++ b/lora/lorawan/bytes.go @@ -13,11 +13,8 @@ func reverseBytes(s []byte) []byte { // GetRand16 returns 2 random bytes func GetRand16() ([2]uint8, error) { - randomBytes := make([]byte, 2) - _, err := rand.Read(randomBytes) - if err != nil { - return [2]uint8{}, err - } + var randomBytes [2]byte + _, err := rand.Read(randomBytes[:]) - return [2]uint8{randomBytes[0], randomBytes[1]}, nil + return randomBytes, err }