FAQ
Reviewers: rsc, r,

Message:
Hello rsc@golang.org, r@golang.org (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.

This change updates CL 6576057 for exceptional cases where
return values from Syscall/RawSyscall functions are used.

The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

Please review this at http://codereview.appspot.com/6590047/

Affected files:
M src/pkg/syscall/exec_plan9.go
M src/pkg/syscall/syscall_plan9.go


Index: src/pkg/syscall/exec_plan9.go
===================================================================
--- a/src/pkg/syscall/exec_plan9.go
+++ b/src/pkg/syscall/exec_plan9.go
@@ -207,7 +207,7 @@
r1, _, _ = RawSyscall(SYS_RFORK, uintptr(RFPROC|RFFDG|RFREND|clearenv|
rflag), 0, 0)

if r1 != 0 {
- if int(r1) == -1 {
+ if int32(r1) == -1 {
return 0, NewError(errstr())
}
// parent; return PID
@@ -219,7 +219,7 @@
// Close fds we don't need.
for i = 0; i < len(fdsToClose); i++ {
r1, _, _ = RawSyscall(SYS_CLOSE, uintptr(fdsToClose[i]), 0, 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}
}
@@ -229,7 +229,7 @@
for i = 0; i < len(envv); i++ {
r1, _, _ = RawSyscall(SYS_CREATE,
uintptr(unsafe.Pointer(envv[i].name)), uintptr(O_WRONLY), uintptr(0666))

- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}

@@ -238,13 +238,13 @@
r1, _, _ = RawSyscall6(SYS_PWRITE, uintptr(envfd),
uintptr(unsafe.Pointer(envv[i].value)), uintptr(envv[i].nvalue),
^uintptr(0), ^uintptr(0), 0)

- if int(r1) == -1 || int(r1) != envv[i].nvalue {
+ if int32(r1) == -1 || int(r1) != envv[i].nvalue {
goto childerror
}

r1, _, _ = RawSyscall(SYS_CLOSE, uintptr(envfd), 0, 0)

- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}
}
@@ -253,7 +253,7 @@
// Chdir
if dir != nil {
r1, _, _ = RawSyscall(SYS_CHDIR, uintptr(unsafe.Pointer(dir)), 0, 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}
}
@@ -263,7 +263,7 @@
nextfd = int(len(fd))
if pipe < nextfd {
r1, _, _ = RawSyscall(SYS_DUP, uintptr(pipe), uintptr(nextfd), 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}
pipe = nextfd
@@ -272,7 +272,7 @@
for i = 0; i < len(fd); i++ {
if fd[i] >= 0 && fd[i] < int(i) {
r1, _, _ = RawSyscall(SYS_DUP, uintptr(fd[i]), uintptr(nextfd), 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}

@@ -294,7 +294,7 @@
continue
}
r1, _, _ = RawSyscall(SYS_DUP, uintptr(fd[i]), uintptr(i), 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
goto childerror
}
}
@@ -519,7 +519,7 @@
func Exec(argv0 string, argv []string, envv []string) (err error) {
if envv != nil {
r1, _, _ := RawSyscall(SYS_RFORK, RFCENVG, 0, 0)
- if int(r1) == -1 {
+ if int32(r1) == -1 {
return NewError(errstr())
}

Index: src/pkg/syscall/syscall_plan9.go
===================================================================
--- a/src/pkg/syscall/syscall_plan9.go
+++ b/src/pkg/syscall/syscall_plan9.go
@@ -255,7 +255,7 @@
r0, _, e = Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(namep)), oldptr,
0)
}

- if int(r0) == -1 {
+ if int32(r0) == -1 {
err = e
}
return

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 30, '12 at 9:31p
activeSep 30, '12 at 9:31p
posts1
users1
websitegolang.org

1 user in discussion

Seed: 1 post

People

Translate

site design / logo © 2022 Grokbase