Skip to content

Commit

Permalink
Merge pull request #17895 from callthingsoff/avoid_conversion_uint8_int
Browse files Browse the repository at this point in the history
pkg/netutil: avoid conversion between uint8 and int for GetDefaultHost
  • Loading branch information
ahrtr committed May 1, 2024
2 parents 83754c1 + e50fe39 commit ce45881
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/netutil/routes_linux.go
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/binary"
"fmt"
"net"
"sort"
"slices"
"syscall"

"go.etcd.io/etcd/pkg/v3/cpuutil"
Expand All @@ -48,14 +48,13 @@ func GetDefaultHost() (string, error) {
}

// sort so choice is deterministic
var families []int
var families []uint8
for family := range rmsgs {
families = append(families, int(family))
families = append(families, family)
}
sort.Ints(families)
slices.Sort(families)

for _, f := range families {
family := uint8(f)
for _, family := range families {
if host, err := chooseHost(family, rmsgs[family]); host != "" || err != nil {
return host, err
}
Expand Down

0 comments on commit ce45881

Please sign in to comment.