mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 23:13:40 +00:00
os: Use a uintptr for NewFile
This appears to have been how it is upstream for about 10 years. Using an interface breaks if a file descriptor number is passed directly to `NewFile`, e.g., `NewFile(3, "fuzz_in")` as used in Go 1.18 fuzzing code.
This commit is contained in:
committed by
Ayke
parent
bf23839931
commit
a680bfbb7a
+4
-10
@@ -38,8 +38,8 @@ type file struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFile(fd FileHandle, name string) *File {
|
||||
return &File{&file{fd, name}}
|
||||
func NewFile(fd uintptr, name string) *File {
|
||||
return &File{&file{unixFileHandle(fd), name}}
|
||||
}
|
||||
|
||||
func Pipe() (r *File, w *File, err error) {
|
||||
@@ -48,14 +48,8 @@ func Pipe() (r *File, w *File, err error) {
|
||||
if e != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
r = NewFile(
|
||||
unixFileHandle(p[0]),
|
||||
"|0",
|
||||
)
|
||||
w = NewFile(
|
||||
unixFileHandle(p[1]),
|
||||
"|1",
|
||||
)
|
||||
r = NewFile(uintptr(p[0]), "|0")
|
||||
w = NewFile(uintptr(p[1]), "|1")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user