tests: Do not allow forced type asserts (#20905)

This commit is contained in:
Klaus Post
2025-02-18 08:25:55 -08:00
committed by GitHub
parent aeabac9181
commit 90f5e1e5f6
100 changed files with 371 additions and 358 deletions

View File

@@ -25,10 +25,10 @@ import (
"fmt"
"os"
"strings"
"sync"
"syscall"
"unsafe"
"github.com/minio/minio/internal/bpool"
"golang.org/x/sys/unix"
)
@@ -106,15 +106,15 @@ const blockSize = 8 << 10 // 8192
// By default at least 128 entries in single getdents call (1MiB buffer)
var (
direntPool = sync.Pool{
New: func() interface{} {
direntPool = bpool.Pool[*[]byte]{
New: func() *[]byte {
buf := make([]byte, blockSize*128)
return &buf
},
}
direntNamePool = sync.Pool{
New: func() interface{} {
direntNamePool = bpool.Pool[*[]byte]{
New: func() *[]byte {
buf := make([]byte, blockSize)
return &buf
},
@@ -183,11 +183,10 @@ func readDirFn(dirPath string, fn func(name string, typ os.FileMode) error) erro
}
return osErrToFileErr(err)
}
}
defer syscall.Close(fd)
bufp := direntPool.Get().(*[]byte)
bufp := direntPool.Get()
defer direntPool.Put(bufp)
buf := *bufp
@@ -273,11 +272,11 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
}
defer syscall.Close(fd)
bufp := direntPool.Get().(*[]byte)
bufp := direntPool.Get()
defer direntPool.Put(bufp)
buf := *bufp
nameTmp := direntNamePool.Get().(*[]byte)
nameTmp := direntNamePool.Get()
defer direntNamePool.Put(nameTmp)
tmp := *nameTmp