Skip to content

Commit

Permalink
No need to return the same pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
liaud committed Jan 8, 2025
1 parent 773014a commit bb93a77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,18 +811,18 @@ type DecodeData struct {
type RawFragment = []byte
type ValidatedFragment = []byte

func (backend *Backend) ValidateFragmentMatrix(frag RawFragment, rangeM *RangeMatrix) (ValidatedFragment, bool) {
func (backend *Backend) ValidateFragmentMatrix(frag RawFragment, rangeM *RangeMatrix) bool {
fragRangeLen := rangeM.InFragRangeEndExcl - rangeM.InFragRangeStartIncl
if len(frag) != fragRangeLen {
return nil, false
return false
}

result := C.check_matrix_fragment((*C.char)(unsafe.Pointer(&frag[0])), C.int(len(frag)), C.int(rangeM.PieceSize))
if result != C.bool(true) {
return nil, false
return false
}

return frag, true
return true
}

func (backend *Backend) LinearizeMatrix(frags []ValidatedFragment, rangeM *RangeMatrix) (*DecodeData, error) {
Expand Down
4 changes: 2 additions & 2 deletions backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ func TestValidateFragmentMatrix(t *testing.T) {
assert.NotNil(rangeMatrix)

frag := encoded.Data[i][rangeMatrix.InFragRangeStartIncl:rangeMatrix.InFragRangeEndExcl]
_, valid := backend.ValidateFragmentMatrix(frag, rangeMatrix)
valid := backend.ValidateFragmentMatrix(frag, rangeMatrix)
assert.True(valid)

chunkSize := pieceSize + backend.headerSize
Expand All @@ -1027,7 +1027,7 @@ func TestValidateFragmentMatrix(t *testing.T) {
previous := frag[offset+altered]
frag[offset+altered] = previous + 1

_, valid := backend.ValidateFragmentMatrix(frag, rangeMatrix)
valid := backend.ValidateFragmentMatrix(frag, rangeMatrix)

/* libec_version and padding not checked */
if altered >= 63 && altered < 67 {
Expand Down

0 comments on commit bb93a77

Please sign in to comment.