Skip to content

Commit

Permalink
Fix new golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Apr 12, 2023
1 parent eb0e3ab commit 57ef6b9
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 216 deletions.
23 changes: 9 additions & 14 deletions association.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,17 @@ func getAssociationStateString(a uint32) string {

// Association represents an SCTP association
// 13.2. Parameters Necessary per Association (i.e., the TCB)
// Peer : Tag value to be sent in every packet and is received
// Verification: in the INIT or INIT ACK chunk.
// Tag :
//
// My : Tag expected in every inbound packet and sent in the
// Verification: INIT or INIT ACK chunk.
// Peer : Tag value to be sent in every packet and is received
// Verification: in the INIT or INIT ACK chunk.
// Tag :
// State : A state variable indicating what state the association
// : is in, i.e., COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED,
// : SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED,
// : SHUTDOWN-ACK-SENT.
//
// Tag :
// State : A state variable indicating what state the association
//
// : is in, i.e., COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED,
// : SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED,
// : SHUTDOWN-ACK-SENT.
//
// Note: No "CLOSED" state is illustrated since if a
// association is "CLOSED" its TCB SHOULD be removed.
// Note: No "CLOSED" state is illustrated since if a
// association is "CLOSED" its TCB SHOULD be removed.
type Association struct {
bytesReceived uint64
bytesSent uint64
Expand Down
16 changes: 8 additions & 8 deletions association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ func (c *dumbConn) RemoteAddr() net.Addr {
}

// SetDeadline is a stub
func (c *dumbConn) SetDeadline(t time.Time) error {
func (c *dumbConn) SetDeadline(time.Time) error {
return nil
}

// SetReadDeadline is a stub
func (c *dumbConn) SetReadDeadline(t time.Time) error {
func (c *dumbConn) SetReadDeadline(time.Time) error {
return nil
}

// SetWriteDeadline is a stub
func (c *dumbConn) SetWriteDeadline(t time.Time) error {
func (c *dumbConn) SetWriteDeadline(time.Time) error {
return nil
}

Expand Down Expand Up @@ -2342,11 +2342,11 @@ func (c *fakeEchoConn) Close() error {
close(c.closed)
return c.errClose
}
func (c *fakeEchoConn) LocalAddr() net.Addr { return nil }
func (c *fakeEchoConn) RemoteAddr() net.Addr { return nil }
func (c *fakeEchoConn) SetDeadline(t time.Time) error { return nil }
func (c *fakeEchoConn) SetReadDeadline(t time.Time) error { return nil }
func (c *fakeEchoConn) SetWriteDeadline(t time.Time) error { return nil }
func (c *fakeEchoConn) LocalAddr() net.Addr { return nil }
func (c *fakeEchoConn) RemoteAddr() net.Addr { return nil }
func (c *fakeEchoConn) SetDeadline(time.Time) error { return nil }
func (c *fakeEchoConn) SetReadDeadline(time.Time) error { return nil }
func (c *fakeEchoConn) SetWriteDeadline(time.Time) error { return nil }

func TestRoutineLeak(t *testing.T) {
loggerFactory := logging.NewDefaultLoggerFactory()
Expand Down
20 changes: 10 additions & 10 deletions chunk_abort.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be
placed before the ABORT in the SCTP packet or they will be ignored by
the receiver.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 6 |Reserved |T| Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| zero or more Error Causes |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 6 |Reserved |T| Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| zero or more Error Causes |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
type chunkAbort struct {
chunkHeader
Expand Down Expand Up @@ -54,7 +54,7 @@ func (a *chunkAbort) unmarshal(raw []byte) error {

e, err := buildErrorCause(raw[offset:])
if err != nil {
return fmt.Errorf("%w: %v", ErrBuildAbortChunkFailed, err)
return fmt.Errorf("%w: %v", ErrBuildAbortChunkFailed, err) //nolint:errorlint
}

offset += int(e.length())
Expand Down
10 changes: 5 additions & 5 deletions chunk_cookie_ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
/*
chunkCookieAck represents an SCTP Chunk of type chunkCookieAck
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 11 |Chunk Flags | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 11 |Chunk Flags | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
type chunkCookieAck struct {
chunkHeader
Expand Down
16 changes: 8 additions & 8 deletions chunk_cookie_echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
/*
CookieEcho represents an SCTP Chunk of type CookieEcho
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 10 |Chunk Flags | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Cookie |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 10 |Chunk Flags | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Cookie |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
type chunkCookieEcho struct {
chunkHeader
Expand Down
42 changes: 21 additions & 21 deletions chunk_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import (
)

/*
Operation Error (ERROR) (9)
Operation Error (ERROR) (9)
An endpoint sends this chunk to its peer endpoint to notify it of
certain error conditions. It contains one or more error causes. An
Operation Error is not considered fatal in and of itself, but may be
used with an ERROR chunk to report a fatal condition. It has the
following parameters:
An endpoint sends this chunk to its peer endpoint to notify it of
certain error conditions. It contains one or more error causes. An
Operation Error is not considered fatal in and of itself, but may be
used with an ERROR chunk to report a fatal condition. It has the
following parameters:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 9 | Chunk Flags | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\ \
/ one or more Error Causes /
\ \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 9 | Chunk Flags | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\ \
/ one or more Error Causes /
\ \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Chunk Flags: 8 bits
Chunk Flags: 8 bits
Set to 0 on transmit and ignored on receipt.
Set to 0 on transmit and ignored on receipt.
Length: 16 bits (unsigned integer)
Length: 16 bits (unsigned integer)
Set to the size of the chunk in bytes, including the chunk header
and all the Error Cause fields present.
Set to the size of the chunk in bytes, including the chunk header
and all the Error Cause fields present.
*/
type chunkError struct {
chunkHeader
Expand Down Expand Up @@ -61,7 +61,7 @@ func (a *chunkError) unmarshal(raw []byte) error {

e, err := buildErrorCause(raw[offset:])
if err != nil {
return fmt.Errorf("%w: %v", ErrBuildErrorChunkFailed, err)
return fmt.Errorf("%w: %v", ErrBuildErrorChunkFailed, err) //nolint:errorlint
}

offset += int(e.length())
Expand Down
4 changes: 2 additions & 2 deletions chunk_forward_tsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *chunkForwardTSN) unmarshal(raw []byte) error {
s := chunkForwardTSNStream{}

if err := s.unmarshal(c.raw[offset:]); err != nil {
return fmt.Errorf("%w: %v", ErrMarshalStreamFailed, err)
return fmt.Errorf("%w: %v", ErrMarshalStreamFailed, err) //nolint:errorlint
}

c.streams = append(c.streams, s)
Expand All @@ -85,7 +85,7 @@ func (c *chunkForwardTSN) marshal() ([]byte, error) {
for _, s := range c.streams {
b, err := s.marshal()
if err != nil {
return nil, fmt.Errorf("%w: %v", ErrMarshalStreamFailed, err)
return nil, fmt.Errorf("%w: %v", ErrMarshalStreamFailed, err) //nolint:errorlint
}
out = append(out, b...)
}
Expand Down
23 changes: 11 additions & 12 deletions chunk_heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ the present association.
The parameter field contains the Heartbeat Information, which is a
variable-length opaque data structure understood only by the sender.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 4 | Chunk Flags | Heartbeat Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Heartbeat Information TLV (Variable-Length) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 4 | Chunk Flags | Heartbeat Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Heartbeat Information TLV (Variable-Length) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Defined as a variable-length parameter using the format described
in Section 3.2.1, i.e.:
Expand Down Expand Up @@ -60,15 +59,15 @@ func (h *chunkHeartbeat) unmarshal(raw []byte) error {

pType, err := parseParamType(raw[chunkHeaderSize:])
if err != nil {
return fmt.Errorf("%w: %v", ErrParseParamTypeFailed, err)
return fmt.Errorf("%w: %v", ErrParseParamTypeFailed, err) //nolint:errorlint
}
if pType != heartbeatInfo {
return fmt.Errorf("%w: instead have %s", ErrHeartbeatParam, pType.String())
}

p, err := buildParam(pType, raw[chunkHeaderSize:])
if err != nil {
return fmt.Errorf("%w: %v", ErrHeartbeatChunkUnmarshal, err)
return fmt.Errorf("%w: %v", ErrHeartbeatChunkUnmarshal, err) //nolint:errorlint
}
h.params = append(h.params, p)

Expand Down
23 changes: 11 additions & 12 deletions chunk_heartbeat_ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ HEARTBEAT chunk to which this ack is responding.
The parameter field contains a variable-length opaque data structure.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 5 | Chunk Flags | Heartbeat Ack Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Heartbeat Information TLV (Variable-Length) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 5 | Chunk Flags | Heartbeat Ack Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Heartbeat Information TLV (Variable-Length) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Defined as a variable-length parameter using the format described
in Section 3.2.1, i.e.:
Expand All @@ -46,7 +45,7 @@ var (
ErrHeartbeatAckMarshalParam = errors.New("unable to marshal parameter for Heartbeat Ack")
)

func (h *chunkHeartbeatAck) unmarshal(raw []byte) error {
func (h *chunkHeartbeatAck) unmarshal([]byte) error {
return ErrUnimplemented
}

Expand All @@ -66,7 +65,7 @@ func (h *chunkHeartbeatAck) marshal() ([]byte, error) {
for idx, p := range h.params {
pp, err := p.marshal()
if err != nil {
return nil, fmt.Errorf("%w: %v", ErrHeartbeatAckMarshalParam, err)
return nil, fmt.Errorf("%w: %v", ErrHeartbeatAckMarshalParam, err) //nolint:errorlint
}

out = append(out, pp...)
Expand Down
20 changes: 10 additions & 10 deletions chunk_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Init represents an SCTP Chunk of type INIT
See chunkInitCommon for the fixed headers
Variable Parameters Status Type Value
-------------------------------------------------------------
IPv4 IP (Note 1) Optional 5
IPv6 IP (Note 1) Optional 6
Cookie Preservative Optional 9
Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
Host Name IP (Note 3) Optional 11
Supported IP Types (Note 4) Optional 12
Variable Parameters Status Type Value
-------------------------------------------------------------
IPv4 IP (Note 1) Optional 5
IPv6 IP (Note 1) Optional 6
Cookie Preservative Optional 9
Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
Host Name IP (Note 3) Optional 11
Supported IP Types (Note 4) Optional 12
*/
type chunkInit struct {
chunkHeader
Expand Down Expand Up @@ -56,7 +56,7 @@ func (i *chunkInit) unmarshal(raw []byte) error {
}

if err := i.chunkInitCommon.unmarshal(i.raw); err != nil {
return fmt.Errorf("%w: %v", ErrChunkTypeInitUnmarshalFailed, err)
return fmt.Errorf("%w: %v", ErrChunkTypeInitUnmarshalFailed, err) //nolint:errorlint
}

return nil
Expand All @@ -65,7 +65,7 @@ func (i *chunkInit) unmarshal(raw []byte) error {
func (i *chunkInit) marshal() ([]byte, error) {
initShared, err := i.chunkInitCommon.marshal()
if err != nil {
return nil, fmt.Errorf("%w: %v", ErrChunkTypeInitMarshalFailed, err)
return nil, fmt.Errorf("%w: %v", ErrChunkTypeInitMarshalFailed, err) //nolint:errorlint
}

i.chunkHeader.typ = ctInit
Expand Down
20 changes: 10 additions & 10 deletions chunk_init_ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ chunkInitAck represents an SCTP Chunk of type INIT ACK
See chunkInitCommon for the fixed headers
Variable Parameters Status Type Value
-------------------------------------------------------------
State Cookie Mandatory 7
IPv4 IP (Note 1) Optional 5
IPv6 IP (Note 1) Optional 6
Unrecognized Parameter Optional 8
Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
Host Name IP (Note 3) Optional 11<Paste>
Variable Parameters Status Type Value
-------------------------------------------------------------
State Cookie Mandatory 7
IPv4 IP (Note 1) Optional 5
IPv6 IP (Note 1) Optional 6
Unrecognized Parameter Optional 8
Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
Host Name IP (Note 3) Optional 11<Paste>
*/
type chunkInitAck struct {
chunkHeader
Expand Down Expand Up @@ -56,7 +56,7 @@ func (i *chunkInitAck) unmarshal(raw []byte) error {
}

if err := i.chunkInitCommon.unmarshal(i.raw); err != nil {
return fmt.Errorf("%w: %v", ErrInitAckUnmarshalFailed, err)
return fmt.Errorf("%w: %v", ErrInitAckUnmarshalFailed, err) //nolint:errorlint
}

return nil
Expand All @@ -65,7 +65,7 @@ func (i *chunkInitAck) unmarshal(raw []byte) error {
func (i *chunkInitAck) marshal() ([]byte, error) {
initShared, err := i.chunkInitCommon.marshal()
if err != nil {
return nil, fmt.Errorf("%w: %v", ErrInitCommonDataMarshalFailed, err)
return nil, fmt.Errorf("%w: %v", ErrInitCommonDataMarshalFailed, err) //nolint:errorlint
}

i.chunkHeader.typ = ctInitAck
Expand Down
Loading

0 comments on commit 57ef6b9

Please sign in to comment.