From: Alberto Donizetti Date: Thu, 20 Apr 2017 09:13:55 +0000 (+0200) Subject: os: document that NewFile can return nil X-Git-Tag: go1.9beta1~229 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9a432552cb6dad659dd6ff7e3c9ab9defc5c73d2;p=gostls13.git os: document that NewFile can return nil Fixes #20023 Change-Id: I1bec3e69031ffcfd7ad71716be9597ec322528ff Reviewed-on: https://go-review.googlesource.com/41211 Reviewed-by: Russ Cox --- diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index f1f244a8d4..97acb5878d 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -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 { diff --git a/src/os/file_unix.go b/src/os/file_unix.go index c65cfb6d37..86271d53e8 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -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) } diff --git a/src/os/file_windows.go b/src/os/file_windows.go index c5b83b5dfe..3e916ae9b2 100644 --- a/src/os/file_windows.go +++ b/src/os/file_windows.go @@ -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 {