Skip to content

Commit

Permalink
lint: fix overflow false warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WoozyMasta committed Jan 13, 2025
1 parent 2ba925f commit 9fa572f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions pkg/a3sb/rules_dayz.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package a3sb

import (
"fmt"
"strconv"

"github.com/woozymasta/a2s/pkg/keywords/types"
Expand Down Expand Up @@ -37,10 +36,7 @@ func (r *Rules) parseRulesDayZ(data map[string]string) error {
if err != nil {
return err
}
if language > 4294967295 {
return fmt.Errorf("language id %d overflow", language)
}
r.Language = types.ServerLang(language)
r.Language = types.ServerLang(language) // #nosec G115

case "platform":
switch v {
Expand Down Expand Up @@ -88,9 +84,6 @@ func strToUint16(str string) (uint16, error) {
if err != nil {
return 0, err
}
if number > 65535 {
return 0, fmt.Errorf("parse string \"%s\" to uint16 overflow", str)
}

return uint16(number), nil
return uint16(number), nil // #nosec G115
}
6 changes: 3 additions & 3 deletions pkg/keywords/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ParseUint8(val string) uint8 {
return 0
}

return uint8(num)
return uint8(num) // #nosec G115
}

// parseUint16 parses a string into a uint16 with overflow checking.
Expand All @@ -49,7 +49,7 @@ func ParseUint16(val string) uint16 {
return 0
}

return uint16(num)
return uint16(num) // #nosec G115
}

// parseUint32 parses a string into a uint16 with overflow checking.
Expand All @@ -59,7 +59,7 @@ func parseUint32(val string) uint32 {
return 0
}

return uint32(num)
return uint32(num) // #nosec G115
}

// parseFloat64 parses a string into float64.
Expand Down

0 comments on commit 9fa572f

Please sign in to comment.