Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Moore <jamesmoore@loopholelabs.io>
  • Loading branch information
jimmyaxod committed Feb 12, 2025
1 parent f7c3f96 commit 37d375e
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/dev_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func EncodeDevInfo(di *DevInfo) []byte {
}

func DecodeDevInfo(buff []byte) (*DevInfo, error) {
if buff == nil || len(buff) < 19 || buff[0] != CommandDevInfo {
if len(buff) < 19 || buff[0] != CommandDevInfo {
return nil, ErrInvalidPacket
}
size := binary.LittleEndian.Uint64(buff[1:])
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/protocol/packets/dirty_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func EncodeDirtyList(blockSize int, blocks []uint) []byte {
}

func DecodeDirtyList(buff []byte) (int, []uint, error) {
if buff == nil || len(buff) < 9 || buff[0] != CommandDirtyList {
if len(buff) < 9 || buff[0] != CommandDirtyList {
return 0, nil, ErrInvalidPacket
}
blockSize := binary.LittleEndian.Uint32(buff[1:])
Expand All @@ -38,7 +38,7 @@ func EncodeDirtyListResponse() []byte {
}

func DecodeDirtyListResponse(buff []byte) error {
if buff == nil || len(buff) < 1 || buff[0] != CommandDirtyListResponse {
if len(buff) < 1 || buff[0] != CommandDirtyListResponse {
return ErrInvalidPacket
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/dont_need_at.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func EncodeDontNeedAt(offset int64, length int32) []byte {
}

func DecodeDontNeedAt(buff []byte) (int64, int32, error) {
if buff == nil || len(buff) < 13 || buff[0] != CommandDontNeedAt {
if len(buff) < 13 || buff[0] != CommandDontNeedAt {
return 0, 0, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[1:]))
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/protocol/packets/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func EncodeEvent(e *Event) []byte {
}

func DecodeEvent(buff []byte) (*Event, error) {
if buff == nil || len(buff) < 2 || buff[0] != CommandEvent {
if len(buff) < 2 || buff[0] != CommandEvent {
return nil, ErrInvalidPacket
}
e := &Event{Type: EventType(buff[1])}
Expand All @@ -62,7 +62,7 @@ func EncodeEventResponse() []byte {
}

func DecodeEventResponse(buff []byte) error {
if buff == nil || len(buff) < 1 || buff[0] != CommandEventResponse {
if len(buff) < 1 || buff[0] != CommandEventResponse {
return ErrInvalidPacket
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func EncodeHashes(hashes map[uint][sha256.Size]byte) []byte {
}

func DecodeHashes(buff []byte) (map[uint][sha256.Size]byte, error) {
if buff == nil || len(buff) < 1 || buff[0] != CommandHashes {
if len(buff) < 1 || buff[0] != CommandHashes {
return nil, ErrInvalidPacket
}
hashes := make(map[uint][sha256.Size]byte)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/need_at.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func EncodeNeedAt(offset int64, length int32) []byte {
}

func DecodeNeedAt(buff []byte) (int64, int32, error) {
if buff == nil || len(buff) < 13 || buff[0] != CommandNeedAt {
if len(buff) < 13 || buff[0] != CommandNeedAt {
return 0, 0, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[1:]))
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/read_at.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func EncodeReadAt(offset int64, length int32) []byte {
}

func DecodeReadAt(buff []byte) (int64, int32, error) {
if buff == nil || len(buff) < 13 || buff[0] != CommandReadAt {
if len(buff) < 13 || buff[0] != CommandReadAt {
return 0, 0, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[1:]))
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/remove_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func EncodeRemoveDev() []byte {
}

func DecodeRemoveDev(buff []byte) error {
if buff == nil || len(buff) < 1 || buff[0] != CommandRemoveDev {
if len(buff) < 1 || buff[0] != CommandRemoveDev {
return ErrInvalidPacket
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/remove_from_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func EncodeRemoveFromMap(ids []uint64) []byte {
}

func DecodeRemoveFromMap(buff []byte) ([]uint64, error) {
if buff == nil || len(buff) < 5 || buff[0] != CommandRemoveFromMap {
if len(buff) < 5 || buff[0] != CommandRemoveFromMap {
return nil, ErrInvalidPacket
}
length := binary.LittleEndian.Uint32(buff[1:])
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/write_at.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func EncodeWriteAt(offset int64, data []byte) []byte {
}

func DecodeWriteAt(buff []byte) (offset int64, data []byte, err error) {
if buff == nil || len(buff) < 10 || buff[0] != CommandWriteAt || buff[1] != WriteAtData {
if len(buff) < 10 || buff[0] != CommandWriteAt || buff[1] != WriteAtData {
return 0, nil, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[2:]))
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/write_at_comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func EncodeWriteAtComp(offset int64, data []byte) []byte {
}

func DecodeWriteAtComp(buff []byte) (offset int64, data []byte, err error) {
if buff == nil || len(buff) < 10 || buff[0] != CommandWriteAt || buff[1] != WriteAtCompRLE {
if len(buff) < 10 || buff[0] != CommandWriteAt || buff[1] != WriteAtCompRLE {
return 0, nil, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[2:]))
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/write_at_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func EncodeWriteAtHash(offset int64, length int64, hash []byte, dataLocation Dat
}

func DecodeWriteAtHash(buff []byte) (offset int64, length int64, hash []byte, loc DataLocation, err error) {
if buff == nil || len(buff) < 19 || buff[0] != CommandWriteAt || buff[1] != WriteAtHash {
if len(buff) < 19 || buff[0] != CommandWriteAt || buff[1] != WriteAtHash {
return 0, 0, nil, 0, ErrInvalidPacket
}
location := DataLocation(buff[2])
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/protocol/packets/write_at_with_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func EncodeWriteAtWithMap(offset int64, data []byte, idmap map[uint64]uint64) []
}

func DecodeWriteAtWithMap(buff []byte) (int64, []byte, map[uint64]uint64, error) {
if buff == nil || len(buff) < 13 || buff[0] != CommandWriteAtWithMap {
if len(buff) < 13 || buff[0] != CommandWriteAtWithMap {
return 0, nil, nil, ErrInvalidPacket
}
off := int64(binary.LittleEndian.Uint64(buff[1:]))
Expand Down

0 comments on commit 37d375e

Please sign in to comment.