silence new platform specific staticcheck issues

These errors only happen on windows or freebsd. They happen when a
function always returns a hard error there so it assumes the condition
is always true which is not the case on another platform.

We then also need to use nolintlint so it does not trigger on linux
where the nolint is not needed otherwise.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2026-09-04 17:21:15 +02:00
parent 3222b4bc25
commit eea3fa25da
No known key found for this signature in database
GPG key ID: EB145DD938A3CAF2
7 changed files with 21 additions and 21 deletions

View file

@ -980,8 +980,8 @@ func AutocompleteTopCmd(cmd *cobra.Command, args []string, toComplete string) ([
}
return getContainers(cmd, toComplete, completeDefault)
}
descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
descriptors, err := util.GetContainerPidInformationDescriptors() //nolint:staticcheck,nolintlint // false-positives on windows because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
cobra.CompErrorln(err.Error())
return nil, cobra.ShellCompDirectiveNoFileComp
}

View file

@ -61,8 +61,8 @@ func init() {
topFlags(topCommand.Flags())
validate.AddLatestFlag(topCommand, &topOptions.Latest)
descriptors, err := util.GetContainerPidInformationDescriptors()
if err == nil {
descriptors, err := util.GetContainerPidInformationDescriptors() //nolint:staticcheck,nolintlint // false-positives on windows because this always errors there
if err == nil { //nolint:staticcheck,nolintlint
topDescription = fmt.Sprintf("%s\n\n Format Descriptors:\n %s", topDescription, strings.Join(descriptors, ","))
topCommand.Long = topDescription
}
@ -77,8 +77,8 @@ func init() {
func top(cmd *cobra.Command, args []string) error {
if topOptions.ListDescriptors {
descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
descriptors, err := util.GetContainerPidInformationDescriptors() //nolint:staticcheck,nolintlint // false-positives on windows because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
return err
}
fmt.Println(strings.Join(descriptors, "\n"))

View file

@ -42,8 +42,8 @@ func init() {
Parent: podCmd,
})
descriptors, err := util.GetContainerPidInformationDescriptors()
if err == nil {
descriptors, err := util.GetContainerPidInformationDescriptors() //nolint:staticcheck,nolintlint // false-positives on windows because this always errors there
if err == nil { //nolint:staticcheck,nolintlint
topDescription = fmt.Sprintf("%s\n\n Format Descriptors:\n %s", topDescription, strings.Join(descriptors, ","))
topCommand.Long = topDescription
}
@ -57,8 +57,8 @@ func init() {
func top(_ *cobra.Command, args []string) error {
if topOptions.ListDescriptors {
descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
descriptors, err := util.GetContainerPidInformationDescriptors() //nolint:staticcheck,nolintlint // false-positives on windows because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
return err
}
fmt.Println(strings.Join(descriptors, "\n"))

View file

@ -1738,13 +1738,13 @@ func (c *Container) mountStorage() (_ string, deferredErr error) {
return "", err
}
pid, cleanupFunc, err := idmap.CreateUsernsProcess(util.RuntimeSpecToIDtools(uidMappings), util.RuntimeSpecToIDtools(gidMappings))
if err != nil {
pid, cleanupFunc, err := idmap.CreateUsernsProcess(util.RuntimeSpecToIDtools(uidMappings), util.RuntimeSpecToIDtools(gidMappings)) //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
return "", err
}
defer cleanupFunc()
if err := idmap.CreateIDMappedMount(c.config.Rootfs, c.config.Rootfs, pid); err != nil {
if err := idmap.CreateIDMappedMount(c.config.Rootfs, c.config.Rootfs, pid); err != nil { //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
return "", fmt.Errorf("failed to create idmapped mount: %w", err)
}
defer func() {

View file

@ -1327,7 +1327,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
}
func (c *Container) checkpointRestoreSupported(version int) error {
if err := criu.CheckForCriu(version); err != nil {
if err := criu.CheckForCriu(version); err != nil { //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
return err
}
if !c.ociRuntime.SupportsCheckpoint() {

View file

@ -253,12 +253,12 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
lockPath = fmt.Sprintf("%s_%d", define.DefaultRootlessSHMLockPath, rootless.GetRootlessUID())
}
// Set up the lock manager
manager, err = lock.OpenSHMLockManager(lockPath, runtime.config.Engine.NumLocks)
if err != nil {
manager, err = lock.OpenSHMLockManager(lockPath, runtime.config.Engine.NumLocks) //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
switch {
case errors.Is(err, os.ErrNotExist):
manager, err = lock.NewSHMLockManager(lockPath, runtime.config.Engine.NumLocks)
if err != nil {
manager, err = lock.NewSHMLockManager(lockPath, runtime.config.Engine.NumLocks) //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
return nil, fmt.Errorf("failed to get new shm lock manager: %w", err)
}
case errors.Is(err, syscall.ERANGE) && runtime.doRenumber:
@ -271,8 +271,8 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
return nil, fmt.Errorf("removing libpod locks file %s: %w", lockPath, err)
}
manager, err = lock.NewSHMLockManager(lockPath, runtime.config.Engine.NumLocks)
if err != nil {
manager, err = lock.NewSHMLockManager(lockPath, runtime.config.Engine.NumLocks) //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
if err != nil { //nolint:staticcheck,nolintlint
return nil, err
}
default:

View file

@ -95,7 +95,7 @@ func CRImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, restoreOpt
if restoreOptions.Pod != "" {
// Restoring into a Pod requires much newer versions of CRIU
if err := criu.CheckForCriu(criu.PodCriuVersion); err != nil {
if err := criu.CheckForCriu(criu.PodCriuVersion); err != nil { //nolint:staticcheck,nolintlint // false-positives on freebsd because this always errors there
return nil, fmt.Errorf("restoring containers into pod: %w", err)
}
// The runtime also has to support it