From 319d21eddf4ffea3aa164bdda4162c26972ad6c0 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 29 Feb 2024 17:36:28 +0200 Subject: [PATCH] app/vmselect/netstorage: usae unsafe.SliceData instead of deprecated reflect.SliceHeader --- app/vmselect/netstorage/netstorage.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/vmselect/netstorage/netstorage.go b/app/vmselect/netstorage/netstorage.go index 7ad1710cc7..07ac4bac4a 100644 --- a/app/vmselect/netstorage/netstorage.go +++ b/app/vmselect/netstorage/netstorage.go @@ -9,7 +9,6 @@ import ( "net" "net/http" "os" - "reflect" "sort" "strings" "sync" @@ -1396,9 +1395,11 @@ func canAppendToBlockAddrPool(pool, a []tmpBlockAddr) bool { // a doesn't belong to pool return false } - shPool := (*reflect.SliceHeader)(unsafe.Pointer(&pool)) - shA := (*reflect.SliceHeader)(unsafe.Pointer(&a)) - return shPool.Data+uintptr(shPool.Len)*unsafe.Sizeof(tmpBlockAddr{}) == shA.Data+uintptr(shA.Len)*unsafe.Sizeof(tmpBlockAddr{}) + return getBlockAddrsEnd(pool) == getBlockAddrsEnd(a) +} + +func getBlockAddrsEnd(a []tmpBlockAddr) uintptr { + return uintptr(unsafe.Pointer(unsafe.SliceData(a))) + uintptr(len(a))*unsafe.Sizeof(tmpBlockAddr{}) } func (tbfwLocal *tmpBlocksFileWrapperShard) newBlockAddrs() int {