Skip to content

Commit 36786c3

Browse files
committed
list, utils: remove redundant code
The value of root is already an absolute path since commit ede8a86, so it does not make sense to call filepath.Abs() again. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 2436322 commit 36786c3

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

list.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"os"
8-
"path/filepath"
98
"syscall"
109
"text/tabwriter"
1110
"time"
@@ -116,11 +115,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
116115
return nil, err
117116
}
118117
root := context.GlobalString("root")
119-
absRoot, err := filepath.Abs(root)
120-
if err != nil {
121-
return nil, err
122-
}
123-
list, err := os.ReadDir(absRoot)
118+
list, err := os.ReadDir(root)
124119
if err != nil {
125120
fatal(err)
126121
}

utils_linux.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ var errEmptyID = errors.New("container id cannot be empty")
2626
// loadFactory returns the configured factory instance for execing containers.
2727
func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
2828
root := context.GlobalString("root")
29-
abs, err := filepath.Abs(root)
30-
if err != nil {
31-
return nil, err
32-
}
33-
34-
return libcontainer.New(abs)
29+
return libcontainer.New(root)
3530
}
3631

3732
// getContainer returns the specified container instance by loading it from state

0 commit comments

Comments
 (0)