Skip to content

Commit 26f8c7d

Browse files
authored
Merge pull request moby#40647 from thaJeztah/simplify_is_abs
pkg/system: minor linting issues and refactor
2 parents 8bbba72 + f2d49cb commit 26f8c7d

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

pkg/system/filesys_windows.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ func mkdirWithACL(name string, sddl string) error {
130130
// by the daemon. This SHOULD be treated as absolute from a docker processing
131131
// perspective.
132132
func IsAbs(path string) bool {
133-
if !filepath.IsAbs(path) {
134-
if !strings.HasPrefix(path, string(os.PathSeparator)) {
135-
return false
136-
}
133+
if filepath.IsAbs(path) || strings.HasPrefix(path, string(os.PathSeparator)) {
134+
return true
137135
}
138-
return true
136+
return false
139137
}
140138

141139
// The origin of the functions below here are the golang OS and windows packages,

pkg/system/path_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
1313
// Fails if not C drive.
1414
_, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`, pathdriver.LocalPathDriver)
15-
if err == nil || (err != nil && err.Error() != "The specified path is not on the system drive (C:)") {
15+
if err == nil || err.Error() != "The specified path is not on the system drive (C:)" {
1616
t.Fatalf("Expected error for d:")
1717
}
1818

pkg/system/process_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ func IsProcessAlive(pid int) bool {
1313
func KillProcess(pid int) {
1414
p, err := os.FindProcess(pid)
1515
if err == nil {
16-
p.Kill()
16+
_ = p.Kill()
1717
}
1818
}

0 commit comments

Comments
 (0)