aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2018-07-28 17:32:13 +0800
committerGravatar Miek Gieben <miek@miek.nl> 2018-07-28 10:32:13 +0100
commit54ec78c1ba918b98ac9b9c5b1334c9d170502119 (patch)
tree65c80cb2c6f886855183532350aedc02e3ca8ee4
parent62df253371f354200a3efde9e86e80eb50a2441b (diff)
downloadcoredns-54ec78c1ba918b98ac9b9c5b1334c9d170502119.tar.gz
coredns-54ec78c1ba918b98ac9b9c5b1334c9d170502119.tar.zst
coredns-54ec78c1ba918b98ac9b9c5b1334c9d170502119.zip
Fix ineffassign (#1959)
* Fix ineffassign This fix tries to fix ineffassign, as was reported in: https://goreportcard.com/report/github.com/coredns/coredns#ineffassign Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update setup.go Revert this one change, so this can be merged.
-rw-r--r--plugin/federation/setup.go2
-rw-r--r--plugin/file/setup.go3
-rw-r--r--plugin/file/zone.go2
-rw-r--r--plugin/normalize.go3
-rw-r--r--plugin/proxy/lookup.go2
-rw-r--r--plugin/proxy/proxy.go2
-rw-r--r--plugin/secondary/setup.go3
-rw-r--r--test/server_reverse_test.go8
8 files changed, 10 insertions, 15 deletions
diff --git a/plugin/federation/setup.go b/plugin/federation/setup.go
index 72514fe8f..06daaf4e1 100644
--- a/plugin/federation/setup.go
+++ b/plugin/federation/setup.go
@@ -50,7 +50,7 @@ func federationParse(c *caddy.Controller) (*Federation, error) {
for c.Next() {
// federation [zones..]
zones := c.RemainingArgs()
- origins := []string{}
+ var origins []string
if len(zones) > 0 {
origins = make([]string, len(zones))
copy(origins, zones)
diff --git a/plugin/file/setup.go b/plugin/file/setup.go
index 3f8d1969b..457ea5348 100644
--- a/plugin/file/setup.go
+++ b/plugin/file/setup.go
@@ -53,7 +53,6 @@ func setup(c *caddy.Controller) error {
func fileParse(c *caddy.Controller) (Zones, error) {
z := make(map[string]*Zone)
names := []string{}
- origins := []string{}
config := dnsserver.GetConfig(c)
@@ -64,7 +63,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
}
fileName := c.Val()
- origins = make([]string, len(c.ServerBlockKeys))
+ origins := make([]string, len(c.ServerBlockKeys))
copy(origins, c.ServerBlockKeys)
args := c.RemainingArgs()
if len(args) > 0 {
diff --git a/plugin/file/zone.go b/plugin/file/zone.go
index 6e1ec6d69..5aa72175f 100644
--- a/plugin/file/zone.go
+++ b/plugin/file/zone.go
@@ -203,7 +203,7 @@ func (z *Zone) nameFromRight(qname string, i int) (string, bool) {
}
k := 0
- shot := false
+ var shot bool
for j := 1; j <= i; j++ {
k, shot = dns.PrevLabel(qname, j+z.origLen)
if shot {
diff --git a/plugin/normalize.go b/plugin/normalize.go
index fbbe5c826..e44e55385 100644
--- a/plugin/normalize.go
+++ b/plugin/normalize.go
@@ -125,7 +125,8 @@ func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error) {
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
mod := (bits - ones) % sizeDigit
nearest := (bits - ones) + mod
- offset, end := 0, false
+ offset := 0
+ var end bool
for i := 0; i < nearest/sizeDigit; i++ {
offset, end = dns.NextLabel(rev, offset)
if end {
diff --git a/plugin/proxy/lookup.go b/plugin/proxy/lookup.go
index 44bee4b0e..0437e8eb7 100644
--- a/plugin/proxy/lookup.go
+++ b/plugin/proxy/lookup.go
@@ -71,7 +71,7 @@ func (p Proxy) lookup(state request.Request) (*dns.Msg, error) {
}
for {
start := time.Now()
- reply := new(dns.Msg)
+ var reply *dns.Msg
var backendErr error
// Since Select() should give us "up" hosts, keep retrying
diff --git a/plugin/proxy/proxy.go b/plugin/proxy/proxy.go
index 2a8e35096..b12e37f11 100644
--- a/plugin/proxy/proxy.go
+++ b/plugin/proxy/proxy.go
@@ -70,7 +70,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
for {
start := time.Now()
- reply := new(dns.Msg)
+ var reply *dns.Msg
var backendErr error
// Since Select() should give us "up" hosts, keep retrying
diff --git a/plugin/secondary/setup.go b/plugin/secondary/setup.go
index 1a4115831..20dc184ca 100644
--- a/plugin/secondary/setup.go
+++ b/plugin/secondary/setup.go
@@ -49,13 +49,12 @@ func setup(c *caddy.Controller) error {
func secondaryParse(c *caddy.Controller) (file.Zones, error) {
z := make(map[string]*file.Zone)
names := []string{}
- origins := []string{}
upstr := upstream.Upstream{}
for c.Next() {
if c.Val() == "secondary" {
// secondary [origin]
- origins = make([]string, len(c.ServerBlockKeys))
+ origins := make([]string, len(c.ServerBlockKeys))
copy(origins, c.ServerBlockKeys)
args := c.RemainingArgs()
if len(args) > 0 {
diff --git a/test/server_reverse_test.go b/test/server_reverse_test.go
index 6434d867d..00db410bd 100644
--- a/test/server_reverse_test.go
+++ b/test/server_reverse_test.go
@@ -74,10 +74,8 @@ func TestReverse(t *testing.T) {
m := new(dns.Msg)
for i, tc := range tests {
- inaddr := tc.addr
- var err error
if !strings.HasSuffix(tc.addr, ".arpa.") {
- inaddr, err = dns.ReverseAddr(tc.addr)
+ inaddr, err := dns.ReverseAddr(tc.addr)
if err != nil {
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
}
@@ -122,10 +120,8 @@ func TestReverseInAddr(t *testing.T) {
m := new(dns.Msg)
for i, tc := range tests {
- inaddr := tc.addr
- var err error
if !strings.HasSuffix(tc.addr, ".arpa.") {
- inaddr, err = dns.ReverseAddr(tc.addr)
+ inaddr, err := dns.ReverseAddr(tc.addr)
if err != nil {
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
}