Skip to content
Snippets Groups Projects
Commit 4a9d98d4 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Ian Lance Taylor
Browse files

syscall: optimize Getwd on aix

When looking for \0, use clen which may be optimized.

Also, return EINVAL when returned string is empty.

This makes it similar to how it is implemented in *bsd and solaris.

Change-Id: I3e37ed25f47110eafd12c80291f7746de9db7b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/606902


TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@google.com>
Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarCherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
parent b5ee80a8
No related branches found
No related tags found
No related merge requests found
......@@ -119,11 +119,11 @@ func Getwd() (ret string, err error) {
b := make([]byte, len)
err := getcwd(&b[0], len)
if err == nil {
i := 0
for b[i] != 0 {
i++
n := clen(b[:])
if n < 1 {
return "", EINVAL
}
return string(b[0:i]), nil
return string(b[:n]), nil
}
if err != ERANGE {
return "", err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment