mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 06:52:13 +00:00
runtime: The index variable is initialized multiple times in for
Change the variables `mountTypeFieldIdx := 8`, `mntDestIdx := 4` and `netNsMountType := "nsfs"` to const. And unify the variable naming style, modify `mntDestIdx` to `mountDestIdx`. Fixes: #3646 Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
This commit is contained in:
parent
dfbde2e06c
commit
42a878e6c1
@ -94,10 +94,14 @@ func SetupNetworkNamespace(config *vc.NetworkConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
netNsMountType = "nsfs"
|
||||||
|
mountTypeFieldIdx = 8
|
||||||
|
mountDestIdx = 4
|
||||||
|
)
|
||||||
|
|
||||||
// getNetNsFromBindMount returns the network namespace for the bind-mounted path
|
// getNetNsFromBindMount returns the network namespace for the bind-mounted path
|
||||||
func getNetNsFromBindMount(nsPath string, procMountFile string) (string, error) {
|
func getNetNsFromBindMount(nsPath string, procMountFile string) (string, error) {
|
||||||
netNsMountType := "nsfs"
|
|
||||||
|
|
||||||
// Resolve all symlinks in the path as the mountinfo file contains
|
// Resolve all symlinks in the path as the mountinfo file contains
|
||||||
// resolved paths.
|
// resolved paths.
|
||||||
nsPath, err := filepath.EvalSymlinks(nsPath)
|
nsPath, err := filepath.EvalSymlinks(nsPath)
|
||||||
@ -129,14 +133,12 @@ func getNetNsFromBindMount(nsPath string, procMountFile string) (string, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We check here if the mount type is a network namespace mount type, namely "nsfs"
|
// We check here if the mount type is a network namespace mount type, namely "nsfs"
|
||||||
mountTypeFieldIdx := 8
|
|
||||||
if fields[mountTypeFieldIdx] != netNsMountType {
|
if fields[mountTypeFieldIdx] != netNsMountType {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the mount point/destination for the mount
|
// This is the mount point/destination for the mount
|
||||||
mntDestIdx := 4
|
if fields[mountDestIdx] != nsPath {
|
||||||
if fields[mntDestIdx] != nsPath {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user