Skip to content

Commit

Permalink
fix(pkg/bootflow): removing the deprecated reflect calls
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Walter <[email protected]>
  • Loading branch information
walterchris committed Mar 23, 2024
1 parent b0b64bb commit 252bef9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/bootflow/subsystems/trustchains/tpm/command_extend_unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package tpm

import (
"fmt"
"reflect"
"unsafe"
)

func assertSameSlice[E any](a, b []E) error {
aHdr := (*reflect.SliceHeader)(unsafe.Pointer(&a))
bHdr := (*reflect.SliceHeader)(unsafe.Pointer(&b))
if aHdr.Len != bHdr.Len {
return fmt.Errorf("slices have different lengths: %d != %d", aHdr.Len, bHdr.Len)
aHdr := unsafe.SliceData(a)
bHdr := unsafe.SliceData(b)
if len(a) != len(b) {
return fmt.Errorf("slices have different lengths: %d != %d", unsafe.Sizeof(a), unsafe.Sizeof(b))
}
if aHdr.Data != bHdr.Data {
return fmt.Errorf("slice data pointers has different pointers: %X != %X", aHdr.Data, bHdr.Data)

if aHdr != bHdr {
return fmt.Errorf("slice data pointers has different pointers: %X != %X", aHdr, bHdr)
}
return nil
}

0 comments on commit 252bef9

Please sign in to comment.