From ab431f6b91ad02fb9aff6fe0968ce371220cba42 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 14 May 2019 16:47:01 +0000 Subject: [PATCH] root: Fix defer call to be after error check Spotted by runcom: https://github.com/openshift/pivot/pull/47#discussion_r283843586 --- cmd/root.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index bf9fc5f..af20f67 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -102,14 +102,13 @@ func parseTuningFile(tuningFilePath, cmdLinePath string) ([]types.TuneArgument, } // Read and parse the file file, err := os.Open(tuningFilePath) - // Clean up - defer file.Close() - if err != nil { // If we have an issue reading return an error glog.Infof("Unable to open %s for reading: %v", tuningFilePath, err) return addArguments, deleteArguments, err } + // Clean up + defer file.Close() // Parse the tuning lines scanner := bufio.NewScanner(file)