Kaynağa Gözat

Get rid of err altogether by just returning the assignment

Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
Xianglin Gao 8 yıl önce
ebeveyn
işleme
da5d3cccc4
2 değiştirilmiş dosya ile 3 ekleme ve 10 silme
  1. 1 1
      pkg/aaparser/aaparser.go
  2. 2 9
      profiles/apparmor/apparmor.go

+ 1 - 1
pkg/aaparser/aaparser.go

@@ -39,7 +39,7 @@ func cmd(dir string, arg ...string) (string, error) {
 
 	output, err := c.CombinedOutput()
 	if err != nil {
-		return "", fmt.Errorf("running `%s %s` failed with output: %s\nerror: %v", c.Path, strings.Join(c.Args, " "), string(output), err)
+		return "", fmt.Errorf("running `%s %s` failed with output: %s\nerror: %v", c.Path, strings.Join(c.Args, " "), output, err)
 	}
 
 	return string(output), nil

+ 2 - 9
profiles/apparmor/apparmor.go

@@ -54,10 +54,7 @@ func (p *profileData) generateDefault(out io.Writer) error {
 	}
 	p.Version = ver
 
-	if err := compiled.Execute(out, p); err != nil {
-		return err
-	}
-	return nil
+	return compiled.Execute(out, p)
 }
 
 // macrosExists checks if the passed macro exists.
@@ -87,11 +84,7 @@ func InstallDefault(name string) error {
 		return err
 	}
 
-	if err := aaparser.LoadProfile(profilePath); err != nil {
-		return err
-	}
-
-	return nil
+	return aaparser.LoadProfile(profilePath)
 }
 
 // IsLoaded checks if a profile with the given name has been loaded into the