mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
*: ignore errorlint warnings about unix.* errors
Errors from unix.* are always bare and thus can be used directly.
Add //nolint:errorlint annotation to ignore errors such as these:
libcontainer/system/xattrs_linux.go:18:7: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
case errno == unix.ERANGE:
^
libcontainer/container_linux.go:1259:9: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
if e != unix.EINVAL {
^
libcontainer/rootfs_linux.go:919:7: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
if err != unix.EINVAL && err != unix.EPERM {
^
libcontainer/rootfs_linux.go:1002:4: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
switch err {
^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -81,7 +81,7 @@ func prepareOpenat2() error {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
prepErr = &os.PathError{Op: "openat2", Path: cgroupfsDir, Err: err}
|
prepErr = &os.PathError{Op: "openat2", Path: cgroupfsDir, Err: err}
|
||||||
if err != unix.ENOSYS {
|
if err != unix.ENOSYS { //nolint:errorlint // unix errors are bare
|
||||||
logrus.Warnf("falling back to securejoin: %s", prepErr)
|
logrus.Warnf("falling back to securejoin: %s", prepErr)
|
||||||
} else {
|
} else {
|
||||||
logrus.Debug("openat2 not available, falling back to securejoin")
|
logrus.Debug("openat2 not available, falling back to securejoin")
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ func cpusetEnsureParent(current string) error {
|
|||||||
}
|
}
|
||||||
// Treat non-existing directory as cgroupfs as it will be created,
|
// Treat non-existing directory as cgroupfs as it will be created,
|
||||||
// and the root cpuset directory obviously exists.
|
// and the root cpuset directory obviously exists.
|
||||||
if err != nil && err != unix.ENOENT {
|
if err != nil && err != unix.ENOENT { //nolint:errorlint // unix errors are bare
|
||||||
return &os.PathError{Op: "statfs", Path: parent, Err: err}
|
return &os.PathError{Op: "statfs", Path: parent, Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ func EnterPid(cgroupPaths map[string]string, pid int) error {
|
|||||||
|
|
||||||
func rmdir(path string) error {
|
func rmdir(path string) error {
|
||||||
err := unix.Rmdir(path)
|
err := unix.Rmdir(path)
|
||||||
if err == nil || err == unix.ENOENT {
|
if err == nil || err == unix.ENOENT { //nolint:errorlint // unix errors are bare
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &os.PathError{Op: "rmdir", Path: path, Err: err}
|
return &os.PathError{Op: "rmdir", Path: path, Err: err}
|
||||||
|
|||||||
@@ -1256,7 +1256,7 @@ func (c *linuxContainer) prepareCriuRestoreMounts(mounts []*configs.Mount) error
|
|||||||
for _, u := range umounts {
|
for _, u := range umounts {
|
||||||
_ = utils.WithProcfd(c.config.Rootfs, u, func(procfd string) error {
|
_ = utils.WithProcfd(c.config.Rootfs, u, func(procfd string) error {
|
||||||
if e := unix.Unmount(procfd, unix.MNT_DETACH); e != nil {
|
if e := unix.Unmount(procfd, unix.MNT_DETACH); e != nil {
|
||||||
if e != unix.EINVAL {
|
if e != unix.EINVAL { //nolint:errorlint // unix errors are bare
|
||||||
// Ignore EINVAL as it means 'target is not a mount point.'
|
// Ignore EINVAL as it means 'target is not a mount point.'
|
||||||
// It probably has already been unmounted.
|
// It probably has already been unmounted.
|
||||||
logrus.Warnf("Error during cleanup unmounting of %s (%s): %v", procfd, u, e)
|
logrus.Warnf("Error during cleanup unmounting of %s (%s): %v", procfd, u, e)
|
||||||
|
|||||||
@@ -399,6 +399,8 @@ func fixStdioPermissions(config *initConfig, u *user.ExecUser) error {
|
|||||||
// privileged_wrt_inode_uidgid() has failed). In either case, we
|
// privileged_wrt_inode_uidgid() has failed). In either case, we
|
||||||
// are in a configuration where it's better for us to just not
|
// are in a configuration where it's better for us to just not
|
||||||
// touch the stdio rather than bail at this point.
|
// touch the stdio rather than bail at this point.
|
||||||
|
|
||||||
|
// nolint:errorlint // unix errors are bare
|
||||||
if err == unix.EINVAL || err == unix.EPERM {
|
if err == unix.EINVAL || err == unix.EPERM {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ func Lgetxattr(path string, attr string) ([]byte, error) {
|
|||||||
dest := make([]byte, 128)
|
dest := make([]byte, 128)
|
||||||
sz, errno := unix.Lgetxattr(path, attr, dest)
|
sz, errno := unix.Lgetxattr(path, attr, dest)
|
||||||
|
|
||||||
|
//nolint:errorlint // unix errors are bare
|
||||||
switch {
|
switch {
|
||||||
case errno == unix.ENODATA:
|
case errno == unix.ENODATA:
|
||||||
return nil, errno
|
return nil, errno
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ func (h *signalHandler) reap() (exits []exit, err error) {
|
|||||||
for {
|
for {
|
||||||
pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, &rus)
|
pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, &rus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == unix.ECHILD {
|
if err == unix.ECHILD { //nolint:errorlint // unix errors are bare
|
||||||
return exits, nil
|
return exits, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user