Replace fmt.Errorf w/o %-style to errors.New

Using fmt.Errorf for errors that do not have %-style formatting
directives is an overkill. Switch to errors.New.

Found by

	git grep fmt.Errorf | grep -v ^vendor | grep -v '%'

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-06-08 11:24:00 -07:00
parent 242b3283fd
commit 627a06ad92
13 changed files with 57 additions and 42 deletions
+6 -4
View File
@@ -1,7 +1,7 @@
package libcontainer
import (
"fmt"
"errors"
"io"
"math"
"os"
@@ -9,6 +9,8 @@ import (
"github.com/opencontainers/runc/libcontainer/configs"
)
var errInvalidProcess = errors.New("invalid process")
type processOperations interface {
wait() (*os.ProcessState, error)
signal(sig os.Signal) error
@@ -84,7 +86,7 @@ type Process struct {
// Wait releases any resources associated with the Process
func (p Process) Wait() (*os.ProcessState, error) {
if p.ops == nil {
return nil, newGenericError(fmt.Errorf("invalid process"), NoProcessOps)
return nil, newGenericError(errInvalidProcess, NoProcessOps)
}
return p.ops.wait()
}
@@ -94,7 +96,7 @@ func (p Process) Pid() (int, error) {
// math.MinInt32 is returned here, because it's invalid value
// for the kill() system call.
if p.ops == nil {
return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), NoProcessOps)
return math.MinInt32, newGenericError(errInvalidProcess, NoProcessOps)
}
return p.ops.pid(), nil
}
@@ -102,7 +104,7 @@ func (p Process) Pid() (int, error) {
// Signal sends a signal to the Process.
func (p Process) Signal(sig os.Signal) error {
if p.ops == nil {
return newGenericError(fmt.Errorf("invalid process"), NoProcessOps)
return newGenericError(errInvalidProcess, NoProcessOps)
}
return p.ops.signal(sig)
}