Skip to content

Commit

Permalink
oci/namespace: remove unnecessary variable idx
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <[email protected]>
  • Loading branch information
Ma Shimiao committed Dec 22, 2016
1 parent 98fef1c commit 730e099
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions oci/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import specs "github.com/opencontainers/runtime-spec/specs-go"

// RemoveNamespace removes the `nsType` namespace from OCI spec `s`
func RemoveNamespace(s *specs.Spec, nsType specs.NamespaceType) {
idx := -1
for i, n := range s.Linux.Namespaces {
if n.Type == nsType {
idx = i
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
return
}
}
if idx >= 0 {
s.Linux.Namespaces = append(s.Linux.Namespaces[:idx], s.Linux.Namespaces[idx+1:]...)
}
}

0 comments on commit 730e099

Please sign in to comment.