fix some linter warnings

This commit is contained in:
Lucas Clemente
2016-08-23 12:24:33 +02:00
parent d1d53beaa8
commit 126db938d0
7 changed files with 10 additions and 11 deletions

View File

@@ -159,12 +159,11 @@ func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame,
return nil, ErrInvalidAckRanges return nil, ErrInvalidAckRanges
} }
var numTimestampByte byte var numTimestamp byte
numTimestampByte, err = r.ReadByte() numTimestamp, err = r.ReadByte()
if err != nil { if err != nil {
return nil, err return nil, err
} }
numTimestamp := uint8(numTimestampByte)
if numTimestamp > 0 { if numTimestamp > 0 {
// Delta Largest acked // Delta Largest acked
@@ -309,7 +308,7 @@ func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error
gapWritten = 0xFF gapWritten = 0xFF
} }
b.WriteByte(uint8(gapWritten)) b.WriteByte(gapWritten)
switch missingSequenceNumberDeltaLen { switch missingSequenceNumberDeltaLen {
case protocol.PacketNumberLen1: case protocol.PacketNumberLen1:
b.WriteByte(uint8(lengthWritten)) b.WriteByte(uint8(lengthWritten))
@@ -318,7 +317,7 @@ func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error
case protocol.PacketNumberLen4: case protocol.PacketNumberLen4:
utils.WriteUint32(b, uint32(lengthWritten)) utils.WriteUint32(b, uint32(lengthWritten))
case protocol.PacketNumberLen6: case protocol.PacketNumberLen6:
utils.WriteUint48(b, uint64(lengthWritten)) utils.WriteUint48(b, lengthWritten)
} }
numRangesWritten++ numRangesWritten++

View File

@@ -129,7 +129,7 @@ func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte {
cfcw := bytes.NewBuffer([]byte{}) cfcw := bytes.NewBuffer([]byte{})
utils.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow())) utils.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow()))
mspc := bytes.NewBuffer([]byte{}) mspc := bytes.NewBuffer([]byte{})
utils.WriteUint32(mspc, uint32(h.GetMaxStreamsPerConnection())) utils.WriteUint32(mspc, h.GetMaxStreamsPerConnection())
icsl := bytes.NewBuffer([]byte{}) icsl := bytes.NewBuffer([]byte{})
utils.WriteUint32(icsl, uint32(h.GetIdleConnectionStateLifetime()/time.Second)) utils.WriteUint32(icsl, uint32(h.GetIdleConnectionStateLifetime()/time.Second))

View File

@@ -154,7 +154,7 @@ var _ = Describe("ConnectionsParameterManager", func() {
}) })
Context("idle connection state lifetime", func() { Context("idle connection state lifetime", func() {
It("has initial idle conneciton state lifetime", func() { It("has initial idle connection state lifetime", func() {
Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime)) Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime))
}) })

View File

@@ -39,7 +39,7 @@ func ParseHandshakeMessage(r utils.ReadStream) (Tag, map[Tag][]byte, error) {
var dataStart uint32 var dataStart uint32
for indexPos := 0; indexPos < int(nPairs)*8; indexPos += 8 { for indexPos := 0; indexPos < int(nPairs)*8; indexPos += 8 {
tag := Tag(binary.LittleEndian.Uint32(index[indexPos : indexPos+4])) tag := Tag(binary.LittleEndian.Uint32(index[indexPos : indexPos+4]))
dataEnd := uint32(binary.LittleEndian.Uint32(index[indexPos+4 : indexPos+8])) dataEnd := binary.LittleEndian.Uint32(index[indexPos+4 : indexPos+8])
dataLen := dataEnd - dataStart dataLen := dataEnd - dataStart
if dataLen > protocol.CryptoParameterMaxLength { if dataLen > protocol.CryptoParameterMaxLength {

View File

@@ -62,5 +62,5 @@ const DefaultRetransmissionTime = 500 * time.Millisecond
// MinRetransmissionTime is the minimum RTO time // MinRetransmissionTime is the minimum RTO time
const MinRetransmissionTime = 200 * time.Millisecond const MinRetransmissionTime = 200 * time.Millisecond
// ClientHelloMinimumSize is the minimum size the server expectes an inchoate CHLO to have. // ClientHelloMinimumSize is the minimum size the server expects an inchoate CHLO to have.
const ClientHelloMinimumSize = 1024 const ClientHelloMinimumSize = 1024

View File

@@ -23,7 +23,7 @@ var (
func (i ErrorCode) String() string { func (i ErrorCode) String() string {
switch { switch {
case 1 <= i && i <= 14: case 1 <= i && i <= 14:
i -= 1 i--
return _ErrorCode_name_0[_ErrorCode_index_0[i]:_ErrorCode_index_0[i+1]] return _ErrorCode_name_0[_ErrorCode_index_0[i]:_ErrorCode_index_0[i+1]]
case 16 <= i && i <= 20: case 16 <= i && i <= 20:
i -= 16 i -= 16

View File

@@ -167,7 +167,7 @@ func WriteUint16(b *bytes.Buffer, i uint16) {
func RandomBit() (bool, error) { func RandomBit() (bool, error) {
b := make([]byte, 1) b := make([]byte, 1)
_, err := rand.Read(b) _, err := rand.Read(b)
return uint8(b[0])%2 == 0, err return b[0]%2 == 0, err
} }
// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order. // Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order.