Skip to content

Commit

Permalink
Slice len is always non-negative (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Nov 28, 2023
1 parent 81a7aae commit 674f18b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion leopard.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (r *leopardFF16) Split(data []byte) ([][]byte, error) {
// Copy partial shards
copyFrom := data[perShard*fullShards : dataLen]
for i := range padding {
if len(copyFrom) <= 0 {
if len(copyFrom) == 0 {
break
}
copyFrom = copyFrom[copy(padding[i], copyFrom):]
Expand Down
2 changes: 1 addition & 1 deletion leopard8.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (r *leopardFF8) Split(data []byte) ([][]byte, error) {
// Copy partial shards
copyFrom := data[perShard*fullShards : dataLen]
for i := range padding {
if len(copyFrom) <= 0 {
if len(copyFrom) == 0 {
break
}
copyFrom = copyFrom[copy(padding[i], copyFrom):]
Expand Down
4 changes: 2 additions & 2 deletions matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ var errColSizeMismatch = errors.New("column size is not the same for all rows")

func (m matrix) Check() error {
rows := len(m)
if rows <= 0 {
if rows == 0 {
return errInvalidRowSize
}
cols := len(m[0])
if cols <= 0 {
if cols == 0 {
return errInvalidColSize
}

Expand Down
2 changes: 1 addition & 1 deletion reedsolomon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ func (r *reedSolomon) Split(data []byte) ([][]byte, error) {
// Copy partial shards
copyFrom := data[perShard*fullShards : dataLen]
for i := range padding {
if len(copyFrom) <= 0 {
if len(copyFrom) == 0 {
break
}
copyFrom = copyFrom[copy(padding[i], copyFrom):]
Expand Down

0 comments on commit 674f18b

Please sign in to comment.