Commit 2e20f339 authored by Mikio Hara's avatar Mikio Hara

x/net/icmp: make use of strconv

There is no circular dependencies, no need to hesitate to use it.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/185900043
parent 668aea8e
......@@ -8,6 +8,7 @@ package icmp
import (
"net"
"strconv"
"syscall"
)
......@@ -56,7 +57,10 @@ func zoneToUint32(zone string) uint32 {
if ifi, err := net.InterfaceByName(zone); err == nil {
return uint32(ifi.Index)
}
n, _, _ := dtoi(zone, 0)
n, err := strconv.Atoi(zone)
if err != nil {
return 0
}
return uint32(n)
}
......@@ -69,19 +73,3 @@ func last(s string, b byte) int {
}
return i
}
const big = 0xFFFFFF
func dtoi(s string, i0 int) (n int, i int, ok bool) {
n = 0
for i = i0; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ {
n = n*10 + int(s[i]-'0')
if n >= big {
return 0, i, false
}
}
if i == i0 {
return 0, i, false
}
return n, i, true
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment