Skip to content

Commit

Permalink
fix: suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-elliott committed Jul 17, 2024
1 parent 779975b commit ff84bc2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 62 deletions.
59 changes: 0 additions & 59 deletions metadata/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
"errors"
"fmt"
"io"
"math"
"net/http"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -276,60 +274,3 @@ func mdsParseX509Certificate(value string) (certificate *x509.Certificate, err e

return certificate, nil
}

// StringToMailAddressHookFunc decodes a string into a mail.Address or *mail.Address.
func hookDecodeUnsignedInt32() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
switch f.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
break
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
break
case reflect.Float32, reflect.Float64:
break
default:
return data, nil
}

if t.Kind() != reflect.Uint32 {
return data, nil
}

var result uint64

switch i := data.(type) {
case int:
result = uint64(i)
case int8:
result = uint64(i)
case int16:
result = uint64(i)
case int32:
result = uint64(i)
case int64:
result = uint64(i)
case uint:
result = uint64(i)
case uint8:
result = uint64(i)
case uint16:
result = uint64(i)
case uint32:
result = uint64(i)
case uint64:
result = i
case float32:
result = uint64(i)
case float64:
result = uint64(i)
default:
return data, nil
}

if result > math.MaxUint32 {
return 0, nil
}

return uint32(result), nil
}
}
4 changes: 1 addition & 3 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,7 @@ type MDSGetEndpointsResponse struct {
func DefaultUndesiredAuthenticatorStatuses() []AuthenticatorStatus {
undesired := make([]AuthenticatorStatus, len(defaultUndesiredAuthenticatorStatus))

for i := range defaultUndesiredAuthenticatorStatus {
undesired[i] = defaultUndesiredAuthenticatorStatus[i]
}
copy(undesired, defaultUndesiredAuthenticatorStatus[:])

return undesired
}
Expand Down

0 comments on commit ff84bc2

Please sign in to comment.