diff options
author | Andrea Barberio <insomniac@slackware.it> | 2019-05-08 09:45:23 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2019-05-08 11:13:30 +0100 |
commit | c781bfa866afb5cac93f2fcbb5ef9da53a486087 (patch) | |
tree | 8a238ffd60198cd2e5639e4a95ddbdb9068d3f3f | |
parent | 2ecf202a098f82731efe88ed625a463913309124 (diff) |
Addressed various linter warnings
Mostly for dead code and potentially wrong comparisons.
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 4 | ||||
-rw-r--r-- | dhcpv6/dhcpv6relay_test.go | 8 | ||||
-rw-r--r-- | dhcpv6/iputils_test.go | 4 | ||||
-rw-r--r-- | dhcpv6/modifiers.go | 1 | ||||
-rw-r--r-- | dhcpv6/nclient6/client.go | 11 | ||||
-rw-r--r-- | dhcpv6/nclient6/client_test.go | 6 | ||||
-rw-r--r-- | dhcpv6/option_iaprefix_test.go | 2 | ||||
-rw-r--r-- | dhcpv6/ztpv6/parse_remote_id_test.go | 1 | ||||
-rw-r--r-- | dhcpv6/ztpv6/parse_vendor_options_test.go | 8 |
9 files changed, 19 insertions, 26 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index 5de2294..fbf7761 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -193,12 +193,12 @@ func TestNewReplyFromMessage(t *testing.T) { require.Equal(t, rep.Type(), MessageTypeReply) msg.MessageType = MessageTypeSolicit - rep, err = NewReplyFromMessage(&msg) + _, err = NewReplyFromMessage(&msg) require.Error(t, err) msg.MessageType = MessageTypeSolicit msg.AddOption(&OptionGeneric{OptionCode: OptionRapidCommit}) - rep, err = NewReplyFromMessage(&msg) + _, err = NewReplyFromMessage(&msg) require.NoError(t, err) msg.Options.Del(OptionRapidCommit) } diff --git a/dhcpv6/dhcpv6relay_test.go b/dhcpv6/dhcpv6relay_test.go index 270dd52..3e7853f 100644 --- a/dhcpv6/dhcpv6relay_test.go +++ b/dhcpv6/dhcpv6relay_test.go @@ -25,10 +25,10 @@ func TestRelayMessage(t *testing.T) { if hc := r.HopCount; hc != 10 { t.Fatalf("Invalid hop count. Expected 10, got %v", hc) } - if la := r.LinkAddr; !bytes.Equal(la, ll) { + if la := r.LinkAddr; !la.Equal(ll) { t.Fatalf("Invalid link address. Expected %v, got %v", ll, la) } - if pa := r.PeerAddr; !bytes.Equal(pa, ma) { + if pa := r.PeerAddr; !pa.Equal(ma) { t.Fatalf("Invalid peer address. Expected %v, got %v", ma, pa) } if opts := r.Options; len(opts) != 0 { @@ -109,8 +109,8 @@ func TestNewRelayRepFromRelayForw(t *testing.T) { require.NoError(t, err) require.Equal(t, m, a) - rr, err = NewRelayReplFromRelayForw(nil, a) + _, err = NewRelayReplFromRelayForw(nil, a) require.Error(t, err) - rr, err = NewRelayReplFromRelayForw(&rf, nil) + _, err = NewRelayReplFromRelayForw(&rf, nil) require.Error(t, err) } diff --git a/dhcpv6/iputils_test.go b/dhcpv6/iputils_test.go index e033d57..e206aa1 100644 --- a/dhcpv6/iputils_test.go +++ b/dhcpv6/iputils_test.go @@ -148,13 +148,13 @@ func Test_ExtractMAC(t *testing.T) { // no client ID solicit, err = NewMessage() require.NoError(t, err) - mac, err = ExtractMAC(solicit) + _, err = ExtractMAC(solicit) require.Error(t, err) // DUID is not DuidLL or DuidLLT duid = Duid{} solicit, err = NewMessage(WithClientID(duid)) require.NoError(t, err) - mac, err = ExtractMAC(solicit) + _, err = ExtractMAC(solicit) require.Error(t, err) } diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go index 200a602..efd14a5 100644 --- a/dhcpv6/modifiers.go +++ b/dhcpv6/modifiers.go @@ -41,7 +41,6 @@ func WithNetboot(d DHCPv6) { oro.AddRequestedOption(OptionBootfileURL) oro.AddRequestedOption(OptionBootfileParam) msg.UpdateOption(oro) - return } // WithUserClass adds a user class option to the packet diff --git a/dhcpv6/nclient6/client.go b/dhcpv6/nclient6/client.go index 8b338db..5c18685 100644 --- a/dhcpv6/nclient6/client.go +++ b/dhcpv6/nclient6/client.go @@ -30,11 +30,6 @@ var ( } ) -const ( - maxUDPReceivedPacketSize = 8192 - maxMessageSize = 1500 -) - var ( // ErrNoResponse is returned when no response packet is received. ErrNoResponse = errors.New("no matching response packet received") @@ -204,12 +199,6 @@ func (c *Client) receiveLoop() { // ClientOpt is a function that configures the Client. type ClientOpt func(*Client) -func withBufferCap(n int) ClientOpt { - return func(c *Client) { - c.bufferCap = n - } -} - // WithTimeout configures the retransmission timeout. // // Default is 5 seconds. diff --git a/dhcpv6/nclient6/client_test.go b/dhcpv6/nclient6/client_test.go index 902c7c5..b48f1f1 100644 --- a/dhcpv6/nclient6/client_test.go +++ b/dhcpv6/nclient6/client_test.go @@ -109,6 +109,12 @@ func newPacket(xid dhcpv6.TransactionID) *dhcpv6.Message { return p } +func withBufferCap(n int) ClientOpt { + return func(c *Client) { + c.bufferCap = n + } +} + func TestSendAndReadUntil(t *testing.T) { for _, tt := range []struct { desc string diff --git a/dhcpv6/option_iaprefix_test.go b/dhcpv6/option_iaprefix_test.go index e48594d..6a98b8b 100644 --- a/dhcpv6/option_iaprefix_test.go +++ b/dhcpv6/option_iaprefix_test.go @@ -29,7 +29,7 @@ func TestOptIAPrefix(t *testing.T) { if pr := opt.PrefixLength(); pr != 36 { t.Fatalf("Invalid Prefix Length. Expected 36, got %v", pr) } - if ip := opt.IPv6Prefix(); !bytes.Equal(ip, net.IPv6loopback) { + if ip := opt.IPv6Prefix(); !ip.Equal(net.IPv6loopback) { t.Fatalf("Invalid Prefix Length. Expected %v, got %v", net.IPv6loopback, ip) } } diff --git a/dhcpv6/ztpv6/parse_remote_id_test.go b/dhcpv6/ztpv6/parse_remote_id_test.go index 54fccc9..3f4c02e 100644 --- a/dhcpv6/ztpv6/parse_remote_id_test.go +++ b/dhcpv6/ztpv6/parse_remote_id_test.go @@ -36,7 +36,6 @@ func TestFormatCircuitID(t *testing.T) { name string circuit *CircuitID want string - fail bool }{ {name: "empty", circuit: &CircuitID{}, want: ",,,,"}, {name: "Arista format Port/Vlan", circuit: &CircuitID{Port: "13", Vlan: "2001"}, want: ",,13,,2001"}, diff --git a/dhcpv6/ztpv6/parse_vendor_options_test.go b/dhcpv6/ztpv6/parse_vendor_options_test.go index a494fac..083866c 100644 --- a/dhcpv6/ztpv6/parse_vendor_options_test.go +++ b/dhcpv6/ztpv6/parse_vendor_options_test.go @@ -9,10 +9,10 @@ import ( func TestParseVendorData(t *testing.T) { tt := []struct { - name string - vc, hostname string - want *VendorData - fail bool + name string + vc string + want *VendorData + fail bool }{ {name: "empty", fail: true}, {name: "unknownVendor", vc: "VendorX;BFR10K;XX12345", fail: true, want: nil}, |