windows: errnoErr(): return ENOENT to reduce code duplication

Change-Id: I51c08a4add9c2b31c4bb7c4421dde227b4fff489
GitHub-Last-Rev: ef8ef8646ca90df893bee4cc8d7879dc1a80ebe4
GitHub-Pull-Request: golang/sys#89
Reviewed-on: https://go-review.googlesource.com/c/sys/+/259537
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
Sebastiaan van Stijn
2020-10-09 02:54:20 +00:00
committed by Ian Lance Taylor
parent c1f3e3309c
commit dfb3f7c4e6
3 changed files with 255 additions and 1263 deletions
+3 -7
View File
@@ -303,17 +303,13 @@ func (r *Rets) SetReturnValuesCode() string {
func (r *Rets) useLongHandleErrorCode(retvar string) string {
const code = `if %s {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = %sEINVAL
}
err = errnoErr(e1)
}`
cond := retvar + " == 0"
if r.FailCond != "" {
cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
}
return fmt.Sprintf(code, cond, syscalldot())
return fmt.Sprintf(code, cond)
}
// SetErrorCode returns source code that sets return parameters.
@@ -867,7 +863,7 @@ var (
func errnoErr(e {{syscalldot}}Errno) error {
switch e {
case 0:
return nil
return {{syscalldot}}EINVAL
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}