lint(revive): fix unnecessary-stmt violations (#7978)

This commit is contained in:
Ville Vesilehto
2026-03-30 03:02:03 +03:00
committed by GitHub
parent 867cd8fd6b
commit 6af8fd46fe
5 changed files with 45 additions and 46 deletions

View File

@@ -99,7 +99,6 @@ linters:
disabled: true
- name: unnecessary-stmt
disabled: true
- name: unreachable-code
disabled: true

View File

@@ -65,7 +65,6 @@ func roundRobin(in []dns.RR) []dns.RR {
func roundRobinShuffle(records []dns.RR) {
switch l := len(records); l {
case 0, 1:
break
case 2:
if dns.Id()%2 == 0 {
records[0], records[1] = records[1], records[0]

View File

@@ -90,8 +90,7 @@ func parse(c *caddy.Controller) (string, monitorType, error) {
}
for c.NextBlock() {
switch c.Val() {
case "monitor":
if c.Val() == "monitor" {
args := c.RemainingArgs()
if len(args) != 1 {
return "", "", c.ArgErr()

View File

@@ -69,12 +69,18 @@ func (r *cnameTargetRule) getFromAndToTarget(inputCName string) (from string, to
func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) {
// logic to rewrite the cname target of dns response
switch rr.Header().Rrtype {
case dns.TypeCNAME:
if rr.Header().Rrtype != dns.TypeCNAME {
return
}
// rename the target of the cname response
if cname, ok := rr.(*dns.CNAME); ok {
cname, ok := rr.(*dns.CNAME)
if !ok {
return
}
fromTarget, toTarget := r.rule.getFromAndToTarget(cname.Target)
if cname.Target == fromTarget {
if cname.Target != fromTarget {
return
}
// create upstream request with the new target with the same qtype
r.state.Req.Question[0].Name = toTarget
// upRes can be nil if the internal query path didn't write a response
@@ -110,9 +116,6 @@ func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) {
// if not propagated, the truncated response might get cached,
// and it will be impossible to resolve the full response
res.Truncated = upRes.Truncated
}
}
}
}
func newCNAMERule(nextAction string, args ...string) (Rule, error) {

View File

@@ -133,8 +133,7 @@ func resign(rd io.Reader, now time.Time) (why error) {
i := 0
for rr, ok := zp.Next(); ok; rr, ok = zp.Next() {
switch x := rr.(type) {
case *dns.RRSIG:
if x, ok := rr.(*dns.RRSIG); ok {
if x.TypeCovered != dns.TypeSOA {
continue
}