aboutsummaryrefslogtreecommitdiff
path: root/internal/bufpool
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-21 20:55:37 +0800
committerGravatar Runxi Yu2026-02-21 20:55:37 +0800
commit2cb9c32187f0f14f38ab8124466f0ad17f77c5d0 (patch)
treed747cfe22f48a5c134906eb9efed99c471491be8 /internal/bufpool
parentinternal/zlib: Fix lints (diff)
signatureNo signature
*: Fix nosec
Diffstat (limited to 'internal/bufpool')
-rw-r--r--internal/bufpool/buffers.go4
-rw-r--r--internal/bufpool/buffers_test.go6
2 files changed, 6 insertions, 4 deletions
diff --git a/internal/bufpool/buffers.go b/internal/bufpool/buffers.go
index 59e8ed48..19e3f80a 100644
--- a/internal/bufpool/buffers.go
+++ b/internal/bufpool/buffers.go
@@ -85,7 +85,7 @@ func Borrow(capHint int) Buffer {
*buf = make([]byte, 0, classCap)
}
slice := (*buf)[:0]
- return Buffer{buf: slice, pool: poolIndex(classIdx)} //#nosec:G115
+ return Buffer{buf: slice, pool: poolIndex(classIdx)} //#nosec G115
}
// FromOwned constructs a Buffer from a caller-owned byte slice. The resulting
@@ -167,7 +167,7 @@ func (buf *Buffer) ensureCapacity(needed int) {
buf.returnToPool()
buf.buf = newBuf
if pooled {
- buf.pool = poolIndex(classIdx) //#nosec:G115
+ buf.pool = poolIndex(classIdx) //#nosec G115
} else {
buf.pool = unpooled
}
diff --git a/internal/bufpool/buffers_test.go b/internal/bufpool/buffers_test.go
index a690aad1..70861d33 100644
--- a/internal/bufpool/buffers_test.go
+++ b/internal/bufpool/buffers_test.go
@@ -55,7 +55,8 @@ func TestBorrowUsesLargerPools(t *testing.T) {
}
b := Borrow(request)
- if b.pool != poolIndex(classIdx) { //#nosec:G115
+ //#nosec G115
+ if b.pool != poolIndex(classIdx) {
t.Fatalf("expected pooled buffer in class %d, got %d", classIdx, b.pool)
}
if cap(b.buf) != classCap {
@@ -65,7 +66,8 @@ func TestBorrowUsesLargerPools(t *testing.T) {
b2 := Borrow(request)
defer b2.Release()
- if b2.pool != poolIndex(classIdx) { //#nosec:G115
+ //#nosec G115
+ if b2.pool != poolIndex(classIdx) {
t.Fatalf("expected pooled buffer in class %d on reuse, got %d", classIdx, b2.pool)
}
if cap(b2.buf) != classCap {