Skip to content

Commit ad5b481

Browse files
authored
Merge pull request #4344 from kolyshkin/nilness
ci bumps
2 parents 3d7bc3b + 15ec295 commit ad5b481

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

.github/workflows/validate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
sudo apt -qy install libseccomp-dev
4141
- uses: golangci/golangci-lint-action@v6
4242
with:
43-
version: v1.57
43+
version: v1.59
4444
# Extra linters, only checking new code from a pull request.
4545
- name: lint-extra
4646
if: github.event_name == 'pull_request'

.golangci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ linters:
1111
- errorlint
1212
- unconvert
1313
- unparam
14+
15+
linters-settings:
16+
govet:
17+
enable:
18+
- nilness

libcontainer/container_linux.go

+7-14
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *Container) Status() (Status, error) {
9999
func (c *Container) State() (*State, error) {
100100
c.m.Lock()
101101
defer c.m.Unlock()
102-
return c.currentState()
102+
return c.currentState(), nil
103103
}
104104

105105
// OCIState returns the current container's state information.
@@ -531,7 +531,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
531531
logrus.Debug("runc-dmz: using runc-dmz") // used for tests
532532
} else if errors.Is(err, dmz.ErrNoDmzBinary) {
533533
logrus.Debug("runc-dmz binary not embedded in runc binary, falling back to /proc/self/exe clone")
534-
} else if err != nil {
534+
} else {
535535
return nil, fmt.Errorf("failed to create runc-dmz binary clone: %w", err)
536536
}
537537
} else {
@@ -666,10 +666,7 @@ func (c *Container) newInitProcess(p *Process, cmd *exec.Cmd, comm *processComm)
666666

667667
func (c *Container) newSetnsProcess(p *Process, cmd *exec.Cmd, comm *processComm) (*setnsProcess, error) {
668668
cmd.Env = append(cmd.Env, "_LIBCONTAINER_INITTYPE="+string(initSetns))
669-
state, err := c.currentState()
670-
if err != nil {
671-
return nil, fmt.Errorf("unable to get container state: %w", err)
672-
}
669+
state := c.currentState()
673670
// for setns process, we don't have to set cloneflags as the process namespaces
674671
// will only be set via setns syscall
675672
data, err := c.bootstrapData(0, state.NamespacePaths)
@@ -847,12 +844,8 @@ func (c *Container) updateState(process parentProcess) (*State, error) {
847844
if process != nil {
848845
c.initProcess = process
849846
}
850-
state, err := c.currentState()
851-
if err != nil {
852-
return nil, err
853-
}
854-
err = c.saveState(state)
855-
if err != nil {
847+
state := c.currentState()
848+
if err := c.saveState(state); err != nil {
856849
return nil, err
857850
}
858851
return state, nil
@@ -938,7 +931,7 @@ func (c *Container) isPaused() (bool, error) {
938931
return state == configs.Frozen, nil
939932
}
940933

941-
func (c *Container) currentState() (*State, error) {
934+
func (c *Container) currentState() *State {
942935
var (
943936
startTime uint64
944937
externalDescriptors []string
@@ -982,7 +975,7 @@ func (c *Container) currentState() (*State, error) {
982975
}
983976
}
984977
}
985-
return state, nil
978+
return state
986979
}
987980

988981
func (c *Container) currentOCIState() (*specs.State, error) {

0 commit comments

Comments
 (0)