Commit 9a432552 authored by Alberto Donizetti's avatar Alberto Donizetti

os: document that NewFile can return nil

Fixes #20023

Change-Id: I1bec3e69031ffcfd7ad71716be9597ec322528ff
Reviewed-on: https://go-review.googlesource.com/41211Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 2d1829b5
......@@ -35,7 +35,9 @@ func (f *File) Fd() uintptr {
return uintptr(f.fd)
}
// NewFile returns a new File with the given file descriptor and name.
// NewFile returns a new File with the given file descriptor and
// name. The returned value will be nil if fd is not a valid file
// descriptor.
func NewFile(fd uintptr, name string) *File {
fdi := int(fd)
if fdi < 0 {
......
......@@ -59,7 +59,9 @@ func (f *File) Fd() uintptr {
return uintptr(f.pfd.Sysfd)
}
// NewFile returns a new File with the given file descriptor and name.
// NewFile returns a new File with the given file descriptor and
// name. The returned value will be nil if fd is not a valid file
// descriptor.
func NewFile(fd uintptr, name string) *File {
return newFile(fd, name, false)
}
......
......@@ -64,7 +64,9 @@ func newConsoleFile(h syscall.Handle, name string) *File {
return newFile(h, name, "console")
}
// NewFile returns a new File with the given file descriptor and name.
// NewFile returns a new File with the given file descriptor and
// name. The returned value will be nil if fd is not a valid file
// descriptor.
func NewFile(fd uintptr, name string) *File {
h := syscall.Handle(fd)
if h == syscall.InvalidHandle {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment