Browse Source

Merge pull request #40647 from thaJeztah/simplify_is_abs

pkg/system: minor linting issues and refactor
Kir Kolyshkin 5 years ago
parent
commit
26f8c7de91
3 changed files with 5 additions and 7 deletions
  1. 3 5
      pkg/system/filesys_windows.go
  2. 1 1
      pkg/system/path_windows_test.go
  3. 1 1
      pkg/system/process_windows.go

+ 3 - 5
pkg/system/filesys_windows.go

@@ -130,12 +130,10 @@ func mkdirWithACL(name string, sddl string) error {
 // by the daemon. This SHOULD be treated as absolute from a docker processing
 // perspective.
 func IsAbs(path string) bool {
-	if !filepath.IsAbs(path) {
-		if !strings.HasPrefix(path, string(os.PathSeparator)) {
-			return false
-		}
+	if filepath.IsAbs(path) || strings.HasPrefix(path, string(os.PathSeparator)) {
+		return true
 	}
-	return true
+	return false
 }
 
 // The origin of the functions below here are the golang OS and windows packages,

+ 1 - 1
pkg/system/path_windows_test.go

@@ -12,7 +12,7 @@ import (
 func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
 	// Fails if not C drive.
 	_, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`, pathdriver.LocalPathDriver)
-	if err == nil || (err != nil && err.Error() != "The specified path is not on the system drive (C:)") {
+	if err == nil || err.Error() != "The specified path is not on the system drive (C:)" {
 		t.Fatalf("Expected error for d:")
 	}
 

+ 1 - 1
pkg/system/process_windows.go

@@ -13,6 +13,6 @@ func IsProcessAlive(pid int) bool {
 func KillProcess(pid int) {
 	p, err := os.FindProcess(pid)
 	if err == nil {
-		p.Kill()
+		_ = p.Kill()
 	}
 }