The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8043

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
* remove unneeded for-loop in create()

Signed-off-by: Tim Rots <tim.r...@protonmail.ch>
From 3bbb97ad0a6b5c25735e2394cea8944dcbdf64be Mon Sep 17 00:00:00 2001
From: Tim Rots <tim.r...@protonmail.ch>
Date: Fri, 16 Oct 2020 13:48:51 +0200
Subject: [PATCH] lxc/init.go: remove for-loop in create()

* remove unneeded for-loop in create()

Signed-off-by: Tim Rots <tim.r...@protonmail.ch>
---
 lxc/init.go | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/lxc/init.go b/lxc/init.go
index ab04aa9f72..51f0343d27 100644
--- a/lxc/init.go
+++ b/lxc/init.go
@@ -84,6 +84,7 @@ func (c *cmdInit) create(conf *config.Config, args []string) 
(lxd.InstanceServer
        var stdinData api.InstancePut
        var devicesMap map[string]map[string]string
        var configMap map[string]string
+       var profiles []string
 
        // If stdin isn't a terminal, read text from it
        if !termios.IsTerminal(getStdinFd()) {
@@ -91,9 +92,7 @@ func (c *cmdInit) create(conf *config.Config, args []string) 
(lxd.InstanceServer
                if err != nil {
                        return nil, "", err
                }
-
-               err = yaml.Unmarshal(contents, &stdinData)
-               if err != nil {
+               if err = yaml.Unmarshal(contents, &stdinData); err != nil {
                        return nil, "", err
                }
        }
@@ -145,10 +144,7 @@ func (c *cmdInit) create(conf *config.Config, args 
[]string) (lxd.InstanceServer
                d = d.UseTarget(c.flagTarget)
        }
 
-       profiles := []string{}
-       for _, p := range c.flagProfile {
-               profiles = append(profiles, p)
-       }
+       profiles = append(profiles, c.flagProfile...)
 
        if !c.global.flagQuiet {
                if name == "" {
@@ -292,14 +288,12 @@ func (c *cmdInit) create(conf *config.Config, args 
[]string) (lxd.InstanceServer
                        Quiet:  c.global.flagQuiet,
                }
 
-               _, err = op.AddHandler(progress.UpdateOp)
-               if err != nil {
+               if _, err = op.AddHandler(progress.UpdateOp); err != nil {
                        progress.Done("")
                        return nil, "", err
                }
 
-               err = utils.CancelableWait(op, &progress)
-               if err != nil {
+               if err = utils.CancelableWait(op, &progress); err != nil {
                        progress.Done("")
                        return nil, "", err
                }
@@ -320,8 +314,7 @@ func (c *cmdInit) create(conf *config.Config, args 
[]string) (lxd.InstanceServer
                        return nil, "", err
                }
 
-               err = op.Wait()
-               if err != nil {
+               if err = op.Wait(); err != nil {
                        return nil, "", err
                }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to