x/sys/unix: allow nil on unix for all variants of Utimes

Fixes golang/go#11830.

Change-Id: Ie6e9f82d05b7c04092b6ee6117238873b746380e
Reviewed-on: https://go-review.googlesource.com/12690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Rob Pike
2015-07-27 05:51:57 +00:00
parent 2c41184ab0
commit 3826714b1e
3 changed files with 35 additions and 10 deletions
+11 -2
View File
@@ -500,7 +500,10 @@ func SysctlUint32(name string) (value uint32, err error) {
//sys utimes(path string, timeval *[2]Timeval) (err error)
func Utimes(path string, tv []Timeval) (err error) {
func Utimes(path string, tv []Timeval) error {
if tv == nil {
return utimes(path, nil)
}
if len(tv) != 2 {
return EINVAL
}
@@ -508,6 +511,9 @@ func Utimes(path string, tv []Timeval) (err error) {
}
func UtimesNano(path string, ts []Timespec) error {
if ts == nil {
return utimes(path, nil)
}
// TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
// isn't supported by darwin so this uses utimes instead
if len(ts) != 2 {
@@ -524,7 +530,10 @@ func UtimesNano(path string, ts []Timespec) error {
//sys futimes(fd int, timeval *[2]Timeval) (err error)
func Futimes(fd int, tv []Timeval) (err error) {
func Futimes(fd int, tv []Timeval) error {
if tv == nil {
return futimes(fd, nil)
}
if len(tv) != 2 {
return EINVAL
}