summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 09:07:06 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 14:36:48 +0900
commit1d14b8ecfba61de524e0266e4a0fddb3b111f235 (patch)
tree8e66d6dada1377f85e58669c416f7f4cf993ee34 /pkg/packet
parent0ae389ad1e7daeaeb354cd4be76b13ece9153e00 (diff)
silence staticcheck warnings
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg/packet')
-rw-r--r--pkg/packet/bgp/bgp.go16
-rw-r--r--pkg/packet/mrt/mrt.go20
-rw-r--r--pkg/packet/rtr/rtr.go4
3 files changed, 18 insertions, 22 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index 941fe185..dfedba9b 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -2496,7 +2496,7 @@ func (er *EVPNMacIPAdvertisementRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
for _, l := range er.Labels {
@@ -2614,7 +2614,7 @@ func (er *EVPNMulticastEthernetTagRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
if err != nil {
return nil, err
@@ -2714,7 +2714,7 @@ func (er *EVPNEthernetSegmentRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
return buf, nil
}
@@ -3980,10 +3980,6 @@ func (v *FlowSpecComponentItem) Len() int {
}
func (v *FlowSpecComponentItem) Serialize() ([]byte, error) {
- if v.Op > math.MaxUint8 {
- return nil, fmt.Errorf("invalid op size: %d", v.Op)
- }
-
order := uint32(math.Log2(float64(v.Len())))
buf := make([]byte, 1+(1<<order))
buf[0] = byte(uint32(v.Op) | order<<4)
@@ -4358,7 +4354,7 @@ func (n *FlowSpecNLRI) Serialize(options ...*MarshallingOption) ([]byte, error)
}
length := n.Len(options...)
if length > 0xfff {
- return nil, fmt.Errorf("Too large: %d", length)
+ return nil, fmt.Errorf("too large: %d", length)
} else if length < 0xf0 {
length -= 1
buf = append([]byte{byte(length)}, buf...)
@@ -4666,7 +4662,7 @@ func (n *OpaqueNLRI) DecodeFromBytes(data []byte, options ...*MarshallingOption)
func (n *OpaqueNLRI) Serialize(options ...*MarshallingOption) ([]byte, error) {
if len(n.Key) > math.MaxUint16 {
- return nil, fmt.Errorf("Key length too big")
+ return nil, fmt.Errorf("key length too big")
}
buf := make([]byte, 2)
binary.BigEndian.PutUint16(buf, uint16(len(n.Key)))
@@ -9677,7 +9673,7 @@ func FlatUpdate(f1, f2 map[string]string) error {
}
}
if conflict {
- return fmt.Errorf("Keys conflict")
+ return fmt.Errorf("keys conflict")
} else {
return nil
}
diff --git a/pkg/packet/mrt/mrt.go b/pkg/packet/mrt/mrt.go
index dc07ba9b..adcdc649 100644
--- a/pkg/packet/mrt/mrt.go
+++ b/pkg/packet/mrt/mrt.go
@@ -461,7 +461,7 @@ type Rib struct {
func (u *Rib) DecodeFromBytes(data []byte) error {
if len(data) < 4 {
- return fmt.Errorf("Not all RibIpv4Unicast message bytes available")
+ return fmt.Errorf("not all RibIpv4Unicast message bytes available")
}
u.SequenceNumber = binary.BigEndian.Uint32(data[:4])
data = data[4:]
@@ -665,9 +665,9 @@ type BGP4MPHeader struct {
func (m *BGP4MPHeader) decodeFromBytes(data []byte) ([]byte, error) {
if m.isAS4 && len(data) < 8 {
- return nil, fmt.Errorf("Not all BGP4MPMessageAS4 bytes available")
+ return nil, fmt.Errorf("not all BGP4MPMessageAS4 bytes available")
} else if !m.isAS4 && len(data) < 4 {
- return nil, fmt.Errorf("Not all BGP4MPMessageAS bytes available")
+ return nil, fmt.Errorf("not all BGP4MPMessageAS bytes available")
}
if m.isAS4 {
@@ -735,7 +735,7 @@ func newBGP4MPHeader(peeras, localas uint32, intfindex uint16, peerip, localip s
if paddr != nil && laddr != nil {
af = bgp.AFI_IP6
} else {
- return nil, fmt.Errorf("Peer IP Address and Local IP Address must have the same address family")
+ return nil, fmt.Errorf("peer IP Address and Local IP Address must have the same address family")
}
}
return &BGP4MPHeader{
@@ -761,7 +761,7 @@ func (m *BGP4MPStateChange) DecodeFromBytes(data []byte) error {
return err
}
if len(rest) < 4 {
- return fmt.Errorf("Not all BGP4MPStateChange bytes available")
+ return fmt.Errorf("not all BGP4MPStateChange bytes available")
}
m.OldState = BGPState(binary.BigEndian.Uint16(rest[:2]))
m.NewState = BGPState(binary.BigEndian.Uint16(rest[2:4]))
@@ -804,7 +804,7 @@ func (m *BGP4MPMessage) DecodeFromBytes(data []byte) error {
}
if len(rest) < bgp.BGP_HEADER_LENGTH {
- return fmt.Errorf("Not all BGP4MPMessageAS4 bytes available")
+ return fmt.Errorf("not all BGP4MPMessageAS4 bytes available")
}
msg, err := bgp.ParseBGPMessage(rest)
@@ -903,7 +903,7 @@ func SplitMrt(data []byte, atEOF bool) (advance int, token []byte, err error) {
func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
if len(data) < int(h.Len) {
- return nil, fmt.Errorf("Not all MRT message bytes available. expected: %d, actual: %d", int(h.Len), len(data))
+ return nil, fmt.Errorf("not all MRT message bytes available. expected: %d, actual: %d", int(h.Len), len(data))
}
msg := &MRTMessage{Header: *h}
switch h.Type {
@@ -940,7 +940,7 @@ func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
case RIB_GENERIC_ADDPATH:
isAddPath = true
default:
- return nil, fmt.Errorf("unsupported table dumpv2 subtype: %v\n", subType)
+ return nil, fmt.Errorf("unsupported table dumpv2 subtype: %v", subType)
}
if msg.Body == nil {
@@ -993,10 +993,10 @@ func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
isAddPath: true,
}
default:
- return nil, fmt.Errorf("unsupported bgp4mp subtype: %v\n", subType)
+ return nil, fmt.Errorf("unsupported bgp4mp subtype: %v", subType)
}
default:
- return nil, fmt.Errorf("unsupported type: %v\n", h.Type)
+ return nil, fmt.Errorf("unsupported type: %v", h.Type)
}
err := msg.Body.DecodeFromBytes(data)
if err != nil {
diff --git a/pkg/packet/rtr/rtr.go b/pkg/packet/rtr/rtr.go
index 902f1e62..d332f84b 100644
--- a/pkg/packet/rtr/rtr.go
+++ b/pkg/packet/rtr/rtr.go
@@ -355,7 +355,7 @@ func SplitRTR(data []byte, atEOF bool) (advance int, token []byte, err error) {
totalLen := binary.BigEndian.Uint32(data[4:8])
if totalLen < RTR_MIN_LEN {
- return 0, nil, fmt.Errorf("Invalid length: %d", totalLen)
+ return 0, nil, fmt.Errorf("invalid length: %d", totalLen)
}
if uint32(len(data)) < totalLen {
return 0, nil, nil
@@ -385,7 +385,7 @@ func ParseRTR(data []byte) (RTRMessage, error) {
case RTR_ERROR_REPORT:
msg = &RTRErrorReport{}
default:
- return nil, fmt.Errorf("unknown RTR message type %d:", data[1])
+ return nil, fmt.Errorf("unknown RTR message type %d", data[1])
}
err := msg.DecodeFromBytes(data)
return msg, err