From 65ba8ee07e69d52a4452f3d3d7e2ffdb1ab79802 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Feb 2012 00:11:36 -0500 Subject: [PATCH] syscall: make linux Dup2 match other systems You could argue for changing all the others, but Linux is outvoted, and the only time it matters is when newfd==-1, in which case you can call Dup. R=golang-dev, r CC=golang-dev https://golang.org/cl/5650073 --- src/pkg/syscall/syscall_linux.go | 2 +- src/pkg/syscall/zsyscall_linux_386.go | 5 ++--- src/pkg/syscall/zsyscall_linux_amd64.go | 5 ++--- src/pkg/syscall/zsyscall_linux_arm.go | 5 ++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/pkg/syscall/syscall_linux.go b/src/pkg/syscall/syscall_linux.go index d0e16271d5..10fbc17a02 100644 --- a/src/pkg/syscall/syscall_linux.go +++ b/src/pkg/syscall/syscall_linux.go @@ -802,7 +802,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri //sys Close(fd int) (err error) //sys Creat(path string, mode uint32) (fd int, err error) //sysnb Dup(oldfd int) (fd int, err error) -//sysnb Dup2(oldfd int, newfd int) (fd int, err error) +//sysnb Dup2(oldfd int, newfd int) (err error) //sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate1(flag int) (fd int, err error) //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) diff --git a/src/pkg/syscall/zsyscall_linux_386.go b/src/pkg/syscall/zsyscall_linux_386.go index 8c3a844754..4910b3c5fb 100644 --- a/src/pkg/syscall/zsyscall_linux_386.go +++ b/src/pkg/syscall/zsyscall_linux_386.go @@ -210,9 +210,8 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - fd = int(r0) +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = e1 } diff --git a/src/pkg/syscall/zsyscall_linux_amd64.go b/src/pkg/syscall/zsyscall_linux_amd64.go index c53fff7a27..2260c4ef2d 100644 --- a/src/pkg/syscall/zsyscall_linux_amd64.go +++ b/src/pkg/syscall/zsyscall_linux_amd64.go @@ -210,9 +210,8 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - fd = int(r0) +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = e1 } diff --git a/src/pkg/syscall/zsyscall_linux_arm.go b/src/pkg/syscall/zsyscall_linux_arm.go index d739139dce..56878721d3 100644 --- a/src/pkg/syscall/zsyscall_linux_arm.go +++ b/src/pkg/syscall/zsyscall_linux_arm.go @@ -210,9 +210,8 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - fd = int(r0) +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := RawSyscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = e1 }