Skip to content

Commit ba1109f

Browse files
database64128mateusz834
authored andcommitted
net: remove redundant cgoLookupCNAME return parameter
`completed bool` just means `err == nil` after CL 446179. While here, add a test for cgoLookupCNAME. Co-authored-by: Mateusz Poliwczak <[email protected]> Change-Id: I6081a089fde3cb27af4fbde6f04301fc3755272c Reviewed-on: https://go-review.googlesource.com/c/go/+/698615 Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Sean Liao <[email protected]> Reviewed-by: Mateusz Poliwczak <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent f74ed44 commit ba1109f

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/net/cgo_stub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func cgoLookupIP(ctx context.Context, network, name string) (addrs []IPAddr, err
3131
panic("cgo stub: cgo not available")
3232
}
3333

34-
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool) {
34+
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error) {
3535
panic("cgo stub: cgo not available")
3636
}
3737

src/net/cgo_unix.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ func cgoSockaddr(ip IP, zone string) (*_C_struct_sockaddr, _C_socklen_t) {
297297
return nil, 0
298298
}
299299

300-
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool) {
300+
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error) {
301301
resources, err := resSearch(ctx, name, int(dnsmessage.TypeCNAME), int(dnsmessage.ClassINET))
302302
if err != nil {
303-
return
303+
return "", err
304304
}
305305
cname, err = parseCNAMEFromResources(resources)
306306
if err != nil {
307-
return "", err, false
307+
return "", err
308308
}
309-
return cname, nil, true
309+
return cname, nil
310310
}
311311

312312
// resSearch will make a call to the 'res_nsearch' routine in the C library

src/net/cgo_unix_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package net
88

99
import (
1010
"context"
11+
"internal/testenv"
1112
"testing"
1213
)
1314

@@ -67,3 +68,12 @@ func TestCgoLookupPTRWithCancel(t *testing.T) {
6768
t.Error(err)
6869
}
6970
}
71+
72+
func TestCgoLookupCNAME(t *testing.T) {
73+
mustHaveExternalNetwork(t)
74+
testenv.SkipFlakyNet(t)
75+
defer dnsWaitGroup.Wait()
76+
if _, err := cgoLookupCNAME(t.Context(), "www.iana.org."); err != nil {
77+
t.Error(err)
78+
}
79+
}

src/net/lookup_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ func (r *Resolver) lookupPort(ctx context.Context, network, service string) (int
8787
func (r *Resolver) lookupCNAME(ctx context.Context, name string) (string, error) {
8888
order, conf := systemConf().hostLookupOrder(r, name)
8989
if order == hostLookupCgo {
90-
if cname, err, ok := cgoLookupCNAME(ctx, name); ok {
91-
return cname, err
90+
if cname, err := cgoLookupCNAME(ctx, name); err == nil {
91+
return cname, nil
9292
}
9393
}
9494
return r.goLookupCNAME(ctx, name, order, conf)

0 commit comments

Comments
 (0)