mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
Fix problems reported by staticcheck
`staticcheck` is a golang code analysis tool. https://staticcheck.io/ This commit fixes a lot of problems found in our code. Common problems are: - unnecessary use of fmt.Sprintf - duplicated imports with different names - unnecessary check that a key exists before a delete call There are still a lot of reported problems in the test files but I have not looked at those. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -437,12 +437,8 @@ func (s *InMemoryState) RemoveContainer(ctr *Container) error {
|
||||
}
|
||||
|
||||
// Remove our network aliases
|
||||
if _, ok := s.ctrNetworkAliases[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
}
|
||||
if _, ok := s.ctrNetworks[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
}
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -680,9 +676,7 @@ func (s *InMemoryState) NetworkDisconnect(ctr *Container, network string) error
|
||||
ctrAliases = make(map[string][]string)
|
||||
s.ctrNetworkAliases[ctr.ID()] = ctrAliases
|
||||
}
|
||||
if _, ok := ctrAliases[network]; ok {
|
||||
delete(ctrAliases, network)
|
||||
}
|
||||
delete(ctrAliases, network)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1523,12 +1517,8 @@ func (s *InMemoryState) RemoveContainerFromPod(pod *Pod, ctr *Container) error {
|
||||
}
|
||||
|
||||
// Remove our network aliases
|
||||
if _, ok := s.ctrNetworkAliases[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
}
|
||||
if _, ok := s.ctrNetworks[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
}
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user