[lxc-devel] [lxd/master] Extra static analysis fixes

stgraber on Github lxc-bot at linuxcontainers.org
Mon Jul 3 17:57:12 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170703/58640b9b/attachment.bin>
-------------- next part --------------
From 9c42b7af09e34bfeb21ae2cf9dea56f427c06672 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Jul 2017 13:52:42 -0400
Subject: [PATCH 1/4] Fix typos
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/copy.go      | 4 ++--
 lxd/main_init.go | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxc/copy.go b/lxc/copy.go
index befcfc15a..61369eb6c 100644
--- a/lxc/copy.go
+++ b/lxc/copy.go
@@ -190,7 +190,7 @@ func (c *copyCmd) copyContainer(conf *config.Config, sourceResource string, dest
 	}
 
 	// Watch the background operation
-	progress := ProgressRenderer{Format: i18n.G("Transfering container: %s")}
+	progress := ProgressRenderer{Format: i18n.G("Transferring container: %s")}
 	_, err = op.AddHandler(progress.UpdateOp)
 	if err != nil {
 		progress.Done("")
@@ -207,7 +207,7 @@ func (c *copyCmd) copyContainer(conf *config.Config, sourceResource string, dest
 
 	// If choosing a random name, show it to the user
 	if destResource == "" {
-		// Get the succesful operation data
+		// Get the successful operation data
 		opInfo, err := op.GetTarget()
 		if err != nil {
 			return err
diff --git a/lxd/main_init.go b/lxd/main_init.go
index 83c8cec5e..89b2d6bbb 100644
--- a/lxd/main_init.go
+++ b/lxd/main_init.go
@@ -462,7 +462,7 @@ func (cmd *CmdInit) initConfig(client lxd.ContainerServer, config map[string]int
 		return nil, err
 	}
 
-	// Updating the server was sucessful, so return the reverter function
+	// Updating the server was successful, so return the reverter function
 	// in case it's needed later.
 	return reverter, nil
 }

From d28bea60c37d82303cffe39d3017d0e29b545543 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Jul 2017 13:53:25 -0400
Subject: [PATCH 2/4] lxc/image: Missing error handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/image.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lxc/image.go b/lxc/image.go
index 8985a4571..265c8c73f 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -494,6 +494,9 @@ func (c *imageCmd) run(conf *config.Config, args []string) error {
 
 			// Register progress handler
 			_, err = op.AddHandler(progress.UpdateOp)
+			if err != nil {
+				return err
+			}
 
 			// Check if refreshed
 			refreshed := false

From 7d3be5c1d60e7108f53b5035533ab88982623782 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Jul 2017 13:54:12 -0400
Subject: [PATCH 3/4] lxd/container: Fix broken error handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container.go     | 10 +++++++---
 lxd/container_lxc.go |  7 ++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lxd/container.go b/lxd/container.go
index 3baea4595..04a9ceb29 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -849,15 +849,19 @@ func containerConfigureInternal(c container) error {
 		storageTypeName := storage.GetStorageTypeName()
 		if storageTypeName == "lvm" && c.IsRunning() {
 			err = c.ConfigKeySet("volatile.apply_quota", rootDiskDevice["size"])
+			if err != nil {
+				return err
+			}
 		} else {
 			size, err := shared.ParseByteSizeString(rootDiskDevice["size"])
 			if err != nil {
 				return err
 			}
+
 			err = storage.ContainerSetQuota(c, size)
-		}
-		if err != nil {
-			return err
+			if err != nil {
+				return err
+			}
 		}
 	}
 
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index c94bd3b1e..2d97d8509 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3386,10 +3386,11 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
 			if err != nil {
 				return err
 			}
+
 			err = c.storage.ContainerSetQuota(c, size)
-		}
-		if err != nil {
-			return err
+			if err != nil {
+				return err
+			}
 		}
 	}
 

From 86eb0196dbe67d972964d42490f7c3df72de3ad6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Jul 2017 13:56:12 -0400
Subject: [PATCH 4/4] storage/lvm: Fix broken error handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_lvm_utils.go | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index f6bbc2ffe..e85ff0c2e 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -62,6 +62,7 @@ func (s *storageLvm) lvReduce(c container, lvPath string, lvSize int64, fsType s
 		if err != nil {
 			return err
 		}
+
 		if !ourUmount {
 			defer c.StorageStart()
 		}
@@ -77,10 +78,10 @@ func (s *storageLvm) lvReduce(c container, lvPath string, lvSize int64, fsType s
 		ext4LvSizeString := strconv.FormatInt(kbSize, 10)
 		ext4LvSizeString += "K"
 		msg, err = shared.TryRunCommand("resize2fs", lvPath, ext4LvSizeString)
-	}
-	if err != nil {
-		logger.Errorf("could not reduce underlying %s filesystem for LV \"%s\": %s", fsType, lvPath, msg)
-		return fmt.Errorf("could not reduce underlying %s filesystem for LV \"%s\": %s", fsType, lvPath, msg)
+		if err != nil {
+			logger.Errorf("could not reduce underlying %s filesystem for LV \"%s\": %s", fsType, lvPath, msg)
+			return fmt.Errorf("could not reduce underlying %s filesystem for LV \"%s\": %s", fsType, lvPath, msg)
+		}
 	}
 
 	msg, err = shared.TryRunCommand(


More information about the lxc-devel mailing list