Skip to content

Commit

Permalink
Fix gosec error in cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Dec 10, 2024
1 parent 8f791d2 commit f8d5642
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions device/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
8 changes: 4 additions & 4 deletions remote/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -63,5 +63,5 @@ func (c *Control) GetSourceNumber() (uint8, error) {
return 0, err
}

return uint8(number), nil
return uint(number), nil
}

0 comments on commit f8d5642

Please sign in to comment.