From f8d56427b70f0cd81dad112d5e76e990b1b6a1b8 Mon Sep 17 00:00:00 2001 From: Jacalz Date: Tue, 10 Dec 2024 23:35:22 +0100 Subject: [PATCH] Fix gosec error in cast --- device/input.go | 8 ++++---- interactive.go | 2 +- remote/source.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/device/input.go b/device/input.go index 0d27c76..22913cc 100644 --- a/device/input.go +++ b/device/input.go @@ -26,7 +26,7 @@ var ( // NumberFromName returns the corresponding input number for the input name. // NOTE: The output is indexed from 1. -func NumberFromName(device Device, input string) (uint8, error) { +func NumberFromName(device Device, input string) (uint, error) { if device > H590 { return 0, errInvalidDevice } @@ -37,18 +37,18 @@ func NumberFromName(device Device, input string) (uint8, error) { return 0, errInvalidInput } - return uint8(number) + 1, nil // #nosec: Known input! + return uint(number) + 1, nil // #nosec: Known input! } // NameFromNumber returns the corresponding input name for the input number. // NOTE: The input is indexed from 1. -func NameFromNumber(device Device, number uint8) (string, error) { +func NameFromNumber(device Device, number uint) (string, error) { if device > H590 { return "", errInvalidDevice } inputs := deviceInputs[device] - if number > uint8(len(inputs)) { + if number > uint(len(inputs)) { return "", errInvalidInput } diff --git a/interactive.go b/interactive.go index 0e3b4e2..697a99f 100644 --- a/interactive.go +++ b/interactive.go @@ -122,7 +122,7 @@ func handleSourceCommand(subcommands []string, control *remote.Control) { number, err := strconv.ParseUint(subcommands[1], 10, 8) if err == nil { - err = control.SetSourceNumber(uint8(number)) + err = control.SetSourceNumber(uint(number)) } else { err = control.SetSourceName(device.H95, subcommands[1]) } diff --git a/remote/source.go b/remote/source.go index 2d17ea4..78e0ca2 100644 --- a/remote/source.go +++ b/remote/source.go @@ -20,7 +20,7 @@ func (c *Control) SetSourceName(amp device.Device, name string) error { // SetSourceNumber sets the input source to the given number. // This will fail if the source number does not exist on the device. -func (c *Control) SetSourceNumber(number uint8) error { +func (c *Control) SetSourceNumber(number uint) error { parameter := strconv.FormatUint(uint64(number), 10) _, err := fmt.Fprintf(c.conn, commandFormat, "i", parameter) if err != nil { @@ -41,11 +41,11 @@ func (c *Control) GetSourceName(amp device.Device) (string, error) { return "", err } - return device.NameFromNumber(amp, uint8(number)) + return device.NameFromNumber(amp, uint(number)) } // GetSourceNumber returns the currently selected source number. -func (c *Control) GetSourceNumber() (uint8, error) { +func (c *Control) GetSourceNumber() (uint, error) { _, err := fmt.Fprintf(c.conn, commandFormat, "i", "?") if err != nil { return 0, err @@ -63,5 +63,5 @@ func (c *Control) GetSourceNumber() (uint8, error) { return 0, err } - return uint8(number), nil + return uint(number), nil }