]> Cypherpunks repositories - gostls13.git/commitdiff
os: document that NewFile can return nil
authorAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 20 Apr 2017 09:13:55 +0000 (11:13 +0200)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 18 May 2017 17:14:11 +0000 (17:14 +0000)
Fixes #20023

Change-Id: I1bec3e69031ffcfd7ad71716be9597ec322528ff
Reviewed-on: https://go-review.googlesource.com/41211
Reviewed-by: Russ Cox <rsc@golang.org>
src/os/file_plan9.go
src/os/file_unix.go
src/os/file_windows.go

index f1f244a8d4e11e210ca329dacfe8598ea336fddc..97acb5878d8bec763ca50354473c60fd8141630c 100644 (file)
@@ -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 {
index c65cfb6d3711044ea16321307902e5856a3e4650..86271d53e897d1b6bc4618419340a64c0bbe064e 100644 (file)
@@ -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)
 }
index c5b83b5dfeae3504011097bb71349f1ea9f6a9fe..3e916ae9b2da9af84a14f809f1c2a001b6da35c4 100644 (file)
@@ -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 {