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:
Elliott Sales de Andrade
2022-02-06 18:23:29 -05:00
committed by Ayke
parent bf23839931
commit a680bfbb7a
5 changed files with 19 additions and 25 deletions
+5 -5
View File
@@ -10,9 +10,9 @@ import (
// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
// standard output, and standard error file descriptors.
var (
Stdin = NewFile(stdioFileHandle(0), "/dev/stdin")
Stdout = NewFile(stdioFileHandle(1), "/dev/stdout")
Stderr = NewFile(stdioFileHandle(2), "/dev/stderr")
Stdin = NewFile(0, "/dev/stdin")
Stdout = NewFile(1, "/dev/stdout")
Stderr = NewFile(2, "/dev/stderr")
)
// isOS indicates whether we're running on a real operating system with
@@ -32,8 +32,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{stdioFileHandle(fd), name}}
}
// Read is unsupported on this system.