From db15295dfc913fc707ca65d4385a4774033c17bc Mon Sep 17 00:00:00 2001 From: Panos Koutsovasilis Date: Wed, 24 Jan 2024 05:02:05 +0200 Subject: [PATCH] feat: refactor copyInt and readInt to use unsafe.Slice --- auditbeat/tracing/int_aligned.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auditbeat/tracing/int_aligned.go b/auditbeat/tracing/int_aligned.go index f20705115eeb..ea6c52b37bf9 100644 --- a/auditbeat/tracing/int_aligned.go +++ b/auditbeat/tracing/int_aligned.go @@ -29,13 +29,13 @@ import ( var errBadSize = errors.New("bad size for integer") func copyInt(dst unsafe.Pointer, src unsafe.Pointer, len uint8) error { - copy((*(*[maxIntSizeBytes]byte)(dst))[:len], (*(*[maxIntSizeBytes]byte)(src))[:len]) + copy(unsafe.Slice((*byte)(dst))[:len], unsafe.Slice((*byte)(src))[:len]) return nil } func readInt(ptr unsafe.Pointer, len uint8, signed bool) (any, error) { var value any - asSlice := (*(*[maxIntSizeBytes]byte)(ptr))[:] + asSlice := unsafe.Slice((*byte)(ptr), len) switch len { case 1: if signed {