]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: remove redundant type conversion
authorcui fliter <imcusg@gmail.com>
Fri, 30 Sep 2022 03:41:42 +0000 (03:41 +0000)
committerGopher Robot <gobot@golang.org>
Sun, 2 Oct 2022 02:27:38 +0000 (02:27 +0000)
Change-Id: Iae290216687fd1ce8be720600157fb78cc2446d0
GitHub-Last-Rev: 4fba64ecb14a704d39f6ecc33989522bcac6656f
GitHub-Pull-Request: golang/go#55959
Reviewed-on: https://go-review.googlesource.com/c/go/+/436881
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/syscall/exec_bsd.go
src/syscall/exec_freebsd.go
src/syscall/exec_libc.go
src/syscall/exec_libc2.go
src/syscall/exec_linux.go
src/syscall/exec_plan9.go
src/syscall/syscall_aix.go
src/syscall/syscall_bsd.go
src/syscall/syscall_darwin.go

index 3e4c6f9d62f8e2af30a6e87992b91fad31130742..32c3ebdd9b9fe9e7101beafed81a0c22495ae235 100644 (file)
@@ -200,7 +200,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -229,7 +229,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                        RawSyscall(SYS_CLOSE, uintptr(i), 0, 0)
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        // dup2(i, i) won't clear close-on-exec flag on Linux,
                        // probably not elsewhere either.
                        _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_SETFD, 0)
index 851b8fbd06a9177a6dfbb649bed7e7bbc7b9127c..b85bcd93a82bca9b8841b9cce2716c6548f0a5ac 100644 (file)
@@ -223,7 +223,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -242,7 +242,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                        RawSyscall(SYS_CLOSE, uintptr(i), 0, 0)
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        // dup2(i, i) won't clear close-on-exec flag on Linux,
                        // probably not elsewhere either.
                        _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_SETFD, 0)
index 9e14197dcf17c96c7975029e13223c6325ff4d5d..ef0c87e03c461f6c03bf8126371465d7e8db3215 100644 (file)
@@ -215,7 +215,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -243,7 +243,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                        closeFD(uintptr(i))
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        // dup2(i, i) won't clear close-on-exec flag on Linux,
                        // probably not elsewhere either.
                        _, err1 = fcntl1(uintptr(fd[i]), F_SETFD, 0)
index 9eb61a5d35168dac5db6e2cba83a4713a6439a1f..41bc79a721e7d4fa186d1896888f5f0b88e90732 100644 (file)
@@ -198,7 +198,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -225,7 +225,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                        rawSyscall(abi.FuncPCABI0(libc_close_trampoline), uintptr(i), 0, 0)
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        // dup2(i, i) won't clear close-on-exec flag on Linux,
                        // probably not elsewhere either.
                        _, _, err1 = rawSyscall(abi.FuncPCABI0(libc_fcntl_trampoline), uintptr(fd[i]), F_SETFD, 0)
index 72b56f484ac07f0da2399abb42bae705a0d340d2..b61b51dff1d42bc7b8de72b1e90114e07b89633e 100644 (file)
@@ -532,7 +532,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -551,7 +551,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
                        RawSyscall(SYS_CLOSE, uintptr(i), 0, 0)
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        // dup2(i, i) won't clear close-on-exec flag on Linux,
                        // probably not elsewhere either.
                        _, _, err1 = RawSyscall(fcntl64Syscall, uintptr(fd[i]), F_SETFD, 0)
index 6680e6f2ef91c3149b0fd648eb8faf30a5cb36ff..d6b7890f55137f44c019a28743d72ecfa6c1e362 100644 (file)
@@ -245,7 +245,7 @@ dirloop:
                nextfd++
        }
        for i = 0; i < len(fd); i++ {
-               if fd[i] >= 0 && fd[i] < int(i) {
+               if fd[i] >= 0 && fd[i] < i {
                        if nextfd == pipe { // don't stomp on pipe
                                nextfd++
                        }
@@ -265,7 +265,7 @@ dirloop:
                        RawSyscall(SYS_CLOSE, uintptr(i), 0, 0)
                        continue
                }
-               if fd[i] == int(i) {
+               if fd[i] == i {
                        continue
                }
                r1, _, _ = RawSyscall(SYS_DUP, uintptr(fd[i]), uintptr(i), 0)
index dbcb7bb7173170a42976c348bb721ad1ce9a4c73..45a4060f568416996216cf1a1790f7a25d732d59 100644 (file)
@@ -343,7 +343,7 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
        msg.Namelen = uint32(SizeofSockaddrAny)
        var iov Iovec
        if len(p) > 0 {
-               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.Base = &p[0]
                iov.SetLen(len(p))
        }
        var dummy byte
@@ -358,7 +358,7 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
                        iov.Base = &dummy
                        iov.SetLen(1)
                }
-               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.Control = &oob[0]
                msg.SetControllen(len(oob))
        }
        msg.Iov = &iov
@@ -373,11 +373,11 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
 
 func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) {
        var msg Msghdr
-       msg.Name = (*byte)(unsafe.Pointer(ptr))
+       msg.Name = (*byte)(ptr)
        msg.Namelen = uint32(salen)
        var iov Iovec
        if len(p) > 0 {
-               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.Base = &p[0]
                iov.SetLen(len(p))
        }
        var dummy byte
@@ -392,7 +392,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i
                        iov.Base = &dummy
                        iov.SetLen(1)
                }
-               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.Control = &oob[0]
                msg.SetControllen(len(oob))
        }
        msg.Iov = &iov
index 5e636d5258046296d17ecdedd347a904631de3d3..c7a7d786dc5afa0138d87ffba74ba8eb7beb8bd3 100644 (file)
@@ -364,7 +364,7 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
        msg.Namelen = uint32(SizeofSockaddrAny)
        var iov Iovec
        if len(p) > 0 {
-               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.Base = &p[0]
                iov.SetLen(len(p))
        }
        var dummy byte
@@ -374,7 +374,7 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
                        iov.Base = &dummy
                        iov.SetLen(1)
                }
-               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.Control = &oob[0]
                msg.SetControllen(len(oob))
        }
        msg.Iov = &iov
@@ -391,11 +391,11 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
 
 func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) {
        var msg Msghdr
-       msg.Name = (*byte)(unsafe.Pointer(ptr))
+       msg.Name = (*byte)(ptr)
        msg.Namelen = uint32(salen)
        var iov Iovec
        if len(p) > 0 {
-               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.Base = &p[0]
                iov.SetLen(len(p))
        }
        var dummy byte
@@ -405,7 +405,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i
                        iov.Base = &dummy
                        iov.SetLen(1)
                }
-               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.Control = &oob[0]
                msg.SetControllen(len(oob))
        }
        msg.Iov = &iov
index cf9b0e98091ef517cc31402837e176bd11fed45c..a39e99dc633a86df864a1d1e820bcc138b2db4c2 100644 (file)
@@ -227,7 +227,7 @@ func init() {
 
 func fdopendir(fd int) (dir uintptr, err error) {
        r0, _, e1 := syscallPtr(abi.FuncPCABI0(libc_fdopendir_trampoline), uintptr(fd), 0, 0)
-       dir = uintptr(r0)
+       dir = r0
        if e1 != 0 {
                err = errnoErr(e1)
        }