]> Cypherpunks repositories - gostls13.git/commitdiff
os/user: use correct size for initial call in retryWithBuffer
authorIan Lance Taylor <iant@golang.org>
Wed, 30 Aug 2023 18:28:54 +0000 (11:28 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 31 Aug 2023 00:56:17 +0000 (00:56 +0000)
We were accidentally using the sysconf parameter constant.
Change to using the value of that sysconf parameter.

Change-Id: Id7668e7cced0ce7504df99dbbff0757d29dee8c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/524555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/os/user/cgo_lookup_unix.go

index 3735971eb4b7b4b87a456ea1d6b0117c6f087889..402429ba4ac5427bb10ea3788ec31f9cda35c5b7 100644 (file)
@@ -165,8 +165,8 @@ func (k bufferKind) initialSize() _C_size_t {
 // retryWithBuffer repeatedly calls f(), increasing the size of the
 // buffer each time, until f succeeds, fails with a non-ERANGE error,
 // or the buffer exceeds a reasonable limit.
-func retryWithBuffer(startSize bufferKind, f func([]byte) syscall.Errno) error {
-       buf := make([]byte, startSize)
+func retryWithBuffer(kind bufferKind, f func([]byte) syscall.Errno) error {
+       buf := make([]byte, kind.initialSize())
        for {
                errno := f(buf)
                if errno == 0 {