mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
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.
This commit is contained in:
@@ -50,7 +50,7 @@ func federationParse(c *caddy.Controller) (*Federation, error) {
|
|||||||
for c.Next() {
|
for c.Next() {
|
||||||
// federation [zones..]
|
// federation [zones..]
|
||||||
zones := c.RemainingArgs()
|
zones := c.RemainingArgs()
|
||||||
origins := []string{}
|
var origins []string
|
||||||
if len(zones) > 0 {
|
if len(zones) > 0 {
|
||||||
origins = make([]string, len(zones))
|
origins = make([]string, len(zones))
|
||||||
copy(origins, zones)
|
copy(origins, zones)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ func setup(c *caddy.Controller) error {
|
|||||||
func fileParse(c *caddy.Controller) (Zones, error) {
|
func fileParse(c *caddy.Controller) (Zones, error) {
|
||||||
z := make(map[string]*Zone)
|
z := make(map[string]*Zone)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
origins := []string{}
|
|
||||||
|
|
||||||
config := dnsserver.GetConfig(c)
|
config := dnsserver.GetConfig(c)
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
|
|||||||
}
|
}
|
||||||
fileName := c.Val()
|
fileName := c.Val()
|
||||||
|
|
||||||
origins = make([]string, len(c.ServerBlockKeys))
|
origins := make([]string, len(c.ServerBlockKeys))
|
||||||
copy(origins, c.ServerBlockKeys)
|
copy(origins, c.ServerBlockKeys)
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ func (z *Zone) nameFromRight(qname string, i int) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
k := 0
|
k := 0
|
||||||
shot := false
|
var shot bool
|
||||||
for j := 1; j <= i; j++ {
|
for j := 1; j <= i; j++ {
|
||||||
k, shot = dns.PrevLabel(qname, j+z.origLen)
|
k, shot = dns.PrevLabel(qname, j+z.origLen)
|
||||||
if shot {
|
if shot {
|
||||||
|
|||||||
@@ -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.
|
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
|
||||||
mod := (bits - ones) % sizeDigit
|
mod := (bits - ones) % sizeDigit
|
||||||
nearest := (bits - ones) + mod
|
nearest := (bits - ones) + mod
|
||||||
offset, end := 0, false
|
offset := 0
|
||||||
|
var end bool
|
||||||
for i := 0; i < nearest/sizeDigit; i++ {
|
for i := 0; i < nearest/sizeDigit; i++ {
|
||||||
offset, end = dns.NextLabel(rev, offset)
|
offset, end = dns.NextLabel(rev, offset)
|
||||||
if end {
|
if end {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (p Proxy) lookup(state request.Request) (*dns.Msg, error) {
|
|||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
reply := new(dns.Msg)
|
var reply *dns.Msg
|
||||||
var backendErr error
|
var backendErr error
|
||||||
|
|
||||||
// Since Select() should give us "up" hosts, keep retrying
|
// Since Select() should give us "up" hosts, keep retrying
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
reply := new(dns.Msg)
|
var reply *dns.Msg
|
||||||
var backendErr error
|
var backendErr error
|
||||||
|
|
||||||
// Since Select() should give us "up" hosts, keep retrying
|
// Since Select() should give us "up" hosts, keep retrying
|
||||||
|
|||||||
@@ -49,13 +49,12 @@ func setup(c *caddy.Controller) error {
|
|||||||
func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
||||||
z := make(map[string]*file.Zone)
|
z := make(map[string]*file.Zone)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
origins := []string{}
|
|
||||||
upstr := upstream.Upstream{}
|
upstr := upstream.Upstream{}
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
|
|
||||||
if c.Val() == "secondary" {
|
if c.Val() == "secondary" {
|
||||||
// secondary [origin]
|
// secondary [origin]
|
||||||
origins = make([]string, len(c.ServerBlockKeys))
|
origins := make([]string, len(c.ServerBlockKeys))
|
||||||
copy(origins, c.ServerBlockKeys)
|
copy(origins, c.ServerBlockKeys)
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
|
|||||||
@@ -74,10 +74,8 @@ func TestReverse(t *testing.T) {
|
|||||||
|
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
inaddr := tc.addr
|
|
||||||
var err error
|
|
||||||
if !strings.HasSuffix(tc.addr, ".arpa.") {
|
if !strings.HasSuffix(tc.addr, ".arpa.") {
|
||||||
inaddr, err = dns.ReverseAddr(tc.addr)
|
inaddr, err := dns.ReverseAddr(tc.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
|
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
|
||||||
}
|
}
|
||||||
@@ -122,10 +120,8 @@ func TestReverseInAddr(t *testing.T) {
|
|||||||
|
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
inaddr := tc.addr
|
|
||||||
var err error
|
|
||||||
if !strings.HasSuffix(tc.addr, ".arpa.") {
|
if !strings.HasSuffix(tc.addr, ".arpa.") {
|
||||||
inaddr, err = dns.ReverseAddr(tc.addr)
|
inaddr, err := dns.ReverseAddr(tc.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
|
t.Fatalf("Test %d, failed to convert %s", i, tc.addr)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user