From: Mikio Hara Date: Thu, 22 Aug 2013 01:33:06 +0000 (+0900) Subject: net: remove redundant argument check from Dial on udp, unix networks X-Git-Tag: go1.2rc2~457 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3b961bf88b80e350e9d97aa8fba361a10c3f8a7f;p=gostls13.git net: remove redundant argument check from Dial on udp, unix networks The net package consists of thin three layers like the follwoing; - Exposed API, that contains net.Dial, net.DialUDP, net.DialUnix - Socket and network file descriptor, that contains net.netFD and its methods, helper functions such as dialUDP, dialUnix - Network pollster, that contains net.pollDesc and its methods This CL removes redundant argument check which is already done by API layer. R=golang-dev, dave, bradfitz CC=golang-dev https://golang.org/cl/13092043 --- diff --git a/src/pkg/net/udpsock_posix.go b/src/pkg/net/udpsock_posix.go index 1eee64f0c8..3f9230b283 100644 --- a/src/pkg/net/udpsock_posix.go +++ b/src/pkg/net/udpsock_posix.go @@ -170,10 +170,6 @@ func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err er // which must be "udp", "udp4", or "udp6". If laddr is not nil, it is // used as the local address for the connection. func DialUDP(net string, laddr, raddr *UDPAddr) (*UDPConn, error) { - return dialUDP(net, laddr, raddr, noDeadline) -} - -func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, error) { switch net { case "udp", "udp4", "udp6": default: @@ -182,6 +178,10 @@ func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, e if raddr == nil { return nil, &OpError{"dial", net, nil, errMissingAddress} } + return dialUDP(net, laddr, raddr, noDeadline) +} + +func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, error) { fd, err := internetSocket(net, laddr, raddr, deadline, syscall.SOCK_DGRAM, 0, "dial", sockaddrToUDP) if err != nil { return nil, err diff --git a/src/pkg/net/unixsock_posix.go b/src/pkg/net/unixsock_posix.go index 2ae92a0233..94296b92c7 100644 --- a/src/pkg/net/unixsock_posix.go +++ b/src/pkg/net/unixsock_posix.go @@ -247,15 +247,15 @@ func (c *UnixConn) CloseWrite() error { // which must be "unix", "unixgram" or "unixpacket". If laddr is not // nil, it is used as the local address for the connection. func DialUnix(net string, laddr, raddr *UnixAddr) (*UnixConn, error) { - return dialUnix(net, laddr, raddr, noDeadline) -} - -func dialUnix(net string, laddr, raddr *UnixAddr, deadline time.Time) (*UnixConn, error) { switch net { case "unix", "unixgram", "unixpacket": default: return nil, UnknownNetworkError(net) } + return dialUnix(net, laddr, raddr, noDeadline) +} + +func dialUnix(net string, laddr, raddr *UnixAddr, deadline time.Time) (*UnixConn, error) { fd, err := unixSocket(net, laddr, raddr, "dial", deadline) if err != nil { return nil, err