]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove redundant argument check from Dial on udp, unix networks
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 22 Aug 2013 01:33:06 +0000 (10:33 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 22 Aug 2013 01:33:06 +0000 (10:33 +0900)
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

src/pkg/net/udpsock_posix.go
src/pkg/net/unixsock_posix.go

index 1eee64f0c8c485c6d35fa5784826572bf7ec552e..3f9230b28380486c36c20ae4a61674ac0cbf4a60 100644 (file)
@@ -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
index 2ae92a02338c164bacc88092b20ddcee73cb88a6..94296b92c793ca2538f17c4f1a8298bf0dd6a889 100644 (file)
@@ -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