[libvirt] [PATCH] virsh: Define multi line macros properly

Michal Privoznik posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20b5cbd43ca74fc891fe630fe2082d2bdc3f7ea4.1509449965.git.mprivozn@redhat.com
tools/virsh-domain-monitor.c     |  2 +-
tools/virsh-domain.c             | 20 ++++++++++----------
tools/virsh-interface.c          |  2 +-
tools/virsh-network.c            |  2 +-
tools/virsh-pool.c               | 10 +++++-----
tools/virsh-snapshot.c           |  2 +-
tools/virsh-volume.c             |  8 ++++----
tools/virsh.h                    | 12 ++++++------
tools/virt-host-validate-bhyve.c |  2 +-
9 files changed, 30 insertions(+), 30 deletions(-)
[libvirt] [PATCH] virsh: Define multi line macros properly
Posted by Michal Privoznik 6 years, 5 months ago
In some cases there's dangling backward slash at the end of multi
line macros. While technically the code works, it will stop if
some empty lines are removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/virsh-domain-monitor.c     |  2 +-
 tools/virsh-domain.c             | 20 ++++++++++----------
 tools/virsh-interface.c          |  2 +-
 tools/virsh-network.c            |  2 +-
 tools/virsh-pool.c               | 10 +++++-----
 tools/virsh-snapshot.c           |  2 +-
 tools/virsh-volume.c             |  8 ++++----
 tools/virsh.h                    | 12 ++++++------
 tools/virt-host-validate-bhyve.c |  2 +-
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 35d04b22a..e09508248 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -41,7 +41,7 @@
 #include "virstring.h"
 
 #define VIRSH_COMMON_OPT_DOMAIN_FULL                       \
-    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \
+    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid"))
 
 VIR_ENUM_DECL(virshDomainIOError)
 VIR_ENUM_IMPL(virshDomainIOError,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1e33e8295..53ce5b82f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -66,22 +66,22 @@
 #endif
 
 #define VIRSH_COMMON_OPT_DOMAIN_FULL                       \
-    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \
+    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid"))
 
 #define VIRSH_COMMON_OPT_DOMAIN_PERSISTENT             \
     {.name = "persistent",                             \
      .type = VSH_OT_BOOL,                              \
      .help = N_("make live change persistent")         \
-    }                                                  \
+    }
 
 #define VIRSH_COMMON_OPT_DOMAIN_CONFIG                 \
-    VIRSH_COMMON_OPT_CONFIG(N_("affect next boot"))    \
+    VIRSH_COMMON_OPT_CONFIG(N_("affect next boot"))
 
 #define VIRSH_COMMON_OPT_DOMAIN_LIVE                   \
-    VIRSH_COMMON_OPT_LIVE(N_("affect running domain")) \
+    VIRSH_COMMON_OPT_LIVE(N_("affect running domain"))
 
 #define VIRSH_COMMON_OPT_DOMAIN_CURRENT                   \
-    VIRSH_COMMON_OPT_CURRENT(N_("affect current domain")) \
+    VIRSH_COMMON_OPT_CURRENT(N_("affect current domain"))
 
 
 static virDomainPtr
@@ -781,7 +781,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
  * 'average,peak,burst,floor', in which peak and burst are optional,
  * thus 'average,,burst' and 'average,peak' are also legal. */
 
-#define VIRSH_PARSE_RATE_FIELD(index, name)                                      \
+#define VIRSH_PARSE_RATE_FIELD(index, name)                                    \
     do {                                                                       \
         if (index < ntok &&                                                    \
             *tok[index] != '\0' &&                                             \
@@ -1302,7 +1302,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
                                     VIR_DOMAIN_BLOCK_IOTUNE_##CONST,           \
                                     value) < 0)                                \
             goto save_error;                                                   \
-    }                                                                          \
+    }
 
     VSH_ADD_IOTUNE_SCALED(total-bytes-sec, TOTAL_BYTES_SEC);
     VSH_ADD_IOTUNE_SCALED(read-bytes-sec, READ_BYTES_SEC);
@@ -1320,7 +1320,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
                                     VIR_DOMAIN_BLOCK_IOTUNE_##CONST,           \
                                     value) < 0)                                \
             goto save_error;                                                   \
-    }                                                                          \
+    }
 
     VSH_ADD_IOTUNE(total-iops-sec, TOTAL_IOPS_SEC);
     VSH_ADD_IOTUNE(read-iops-sec, READ_IOPS_SEC);
@@ -9096,7 +9096,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
         return false;
 
 #define PARSE_MEMTUNE_PARAM(NAME, FIELD)                                    \
-    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {            \
+    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {          \
         vshError(ctl, _("Unable to parse integer parameter %s"), NAME);     \
         goto cleanup;                                                       \
     }                                                                       \
@@ -9104,7 +9104,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
         if (virTypedParamsAddULLong(&params, &nparams, &maxparams,          \
                                     FIELD, tmpVal) < 0)                     \
             goto save_error;                                                \
-    }                                                                       \
+    }
 
 
     PARSE_MEMTUNE_PARAM("hard-limit", VIR_DOMAIN_MEMORY_HARD_LIMIT);
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 25e21710f..5ca7393d1 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -28,7 +28,7 @@
      .type = VSH_OT_DATA,                              \
      .flags = VSH_OFLAG_REQ,                           \
      .help = N_("interface name or MAC address")       \
-    }                                                  \
+    }
 
 #include <config.h>
 #include "virsh-interface.h"
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index eacc2771b..14f7e7f77 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -39,7 +39,7 @@
      .type = VSH_OT_DATA,                                     \
      .flags = VSH_OFLAG_REQ,                                  \
      .help = N_("network name or uuid")                       \
-    }                                                         \
+    }
 
 virNetworkPtr
 virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 96a623284..58a336de8 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -35,28 +35,28 @@
 #include "virtime.h"
 
 #define VIRSH_COMMON_OPT_POOL_FULL                            \
-    VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))            \
+    VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))
 
 #define VIRSH_COMMON_OPT_POOL_BUILD                           \
     {.name = "build",                                         \
      .type = VSH_OT_BOOL,                                     \
      .flags = 0,                                              \
      .help = N_("build the pool as normal")                   \
-    }                                                         \
+    }
 
 #define VIRSH_COMMON_OPT_POOL_NO_OVERWRITE                        \
     {.name = "no-overwrite",                                      \
      .type = VSH_OT_BOOL,                                         \
      .flags = 0,                                                  \
      .help = N_("do not overwrite any existing data")             \
-    }                                                             \
+    }
 
 #define VIRSH_COMMON_OPT_POOL_OVERWRITE                           \
     {.name = "overwrite",                                         \
      .type = VSH_OT_BOOL,                                         \
      .flags = 0,                                                  \
      .help = N_("overwrite any existing data")                    \
-    }                                                             \
+    }
 
 #define VIRSH_COMMON_OPT_POOL_X_AS                                     \
     {.name = "name",                                                   \
@@ -128,7 +128,7 @@
     {.name = "adapter-parent",                                         \
      .type = VSH_OT_STRING,                                            \
      .help = N_("adapter parent to be used for underlying storage")    \
-    }                                                                  \
+    }
 
 virStoragePoolPtr
 virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 24cd4abd9..8789ee7b0 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -43,7 +43,7 @@
 #include "conf/snapshot_conf.h"
 
 #define VIRSH_COMMON_OPT_DOMAIN_FULL                       \
-    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \
+    VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid"))
 
 /* Helper for snapshot-create and snapshot-create-as */
 static bool
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 0736bdcdb..007657002 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -44,23 +44,23 @@
 #include "virstring.h"
 
 #define VIRSH_COMMON_OPT_POOL_FULL                            \
-    VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))            \
+    VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))
 
 #define VIRSH_COMMON_OPT_POOL_NAME                            \
-    VIRSH_COMMON_OPT_POOL(N_("pool name"))                    \
+    VIRSH_COMMON_OPT_POOL(N_("pool name"))
 
 #define VIRSH_COMMON_OPT_POOL_OPTIONAL                        \
     {.name = "pool",                                          \
      .type = VSH_OT_STRING,                                   \
      .help = N_("pool name or uuid")                          \
-    }                                                         \
+    }
 
 #define VIRSH_COMMON_OPT_VOLUME_VOL                           \
     {.name = "vol",                                           \
      .type = VSH_OT_DATA,                                     \
      .flags = VSH_OFLAG_REQ,                                  \
      .help = N_("vol name, key or path")                      \
-    }                                                         \
+    }
 
 virStorageVolPtr
 virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
diff --git a/tools/virsh.h b/tools/virsh.h
index 9e42ef9bb..9bcf467d4 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -68,39 +68,39 @@
      .type = VSH_OT_DATA,                                         \
      .flags = VSH_OFLAG_REQ,                                      \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 # define VIRSH_COMMON_OPT_DOMAIN(_helpstr)                        \
     {.name = "domain",                                            \
      .type = VSH_OT_DATA,                                         \
      .flags = VSH_OFLAG_REQ,                                      \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 # define VIRSH_COMMON_OPT_CONFIG(_helpstr)                        \
     {.name = "config",                                            \
      .type = VSH_OT_BOOL,                                         \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 # define VIRSH_COMMON_OPT_LIVE(_helpstr)                          \
     {.name = "live",                                              \
      .type = VSH_OT_BOOL,                                         \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 # define VIRSH_COMMON_OPT_CURRENT(_helpstr)                       \
     {.name = "current",                                           \
      .type = VSH_OT_BOOL,                                         \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 # define VIRSH_COMMON_OPT_FILE(_helpstr)                          \
     {.name = "file",                                              \
      .type = VSH_OT_DATA,                                         \
      .flags = VSH_OFLAG_REQ,                                      \
      .help = _helpstr                                             \
-    }                                                             \
+    }
 
 typedef struct _virshControl virshControl;
 typedef virshControl *virshControlPtr;
diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bhyve.c
index c7bf96f05..bd85f8ab0 100644
--- a/tools/virt-host-validate-bhyve.c
+++ b/tools/virt-host-validate-bhyve.c
@@ -37,7 +37,7 @@
                        _("%s module is not loaded, " err_msg), \
                         #mod);                                 \
         ret = -1;                                              \
-    }                                                          \
+    }
 
 #define MODULE_STATUS_FAIL(mod, err_msg) \
     MODULE_STATUS(mod, err_msg, VIR_HOST_VALIDATE_FAIL)
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Define multi line macros properly
Posted by Peter Krempa 6 years, 5 months ago
On Tue, Oct 31, 2017 at 12:39:40 +0100, Michal Privoznik wrote:
> In some cases there's dangling backward slash at the end of multi
> line macros. While technically the code works, it will stop if
> some empty lines are removed.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tools/virsh-domain-monitor.c     |  2 +-
>  tools/virsh-domain.c             | 20 ++++++++++----------
>  tools/virsh-interface.c          |  2 +-
>  tools/virsh-network.c            |  2 +-
>  tools/virsh-pool.c               | 10 +++++-----
>  tools/virsh-snapshot.c           |  2 +-
>  tools/virsh-volume.c             |  8 ++++----
>  tools/virsh.h                    | 12 ++++++------
>  tools/virt-host-validate-bhyve.c |  2 +-
>  9 files changed, 30 insertions(+), 30 deletions(-)

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Define multi line macros properly
Posted by Andrea Bolognani 6 years, 5 months ago
On Tue, 2017-10-31 at 12:39 +0100, Michal Privoznik wrote:
> @@ -781,7 +781,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
>   * 'average,peak,burst,floor', in which peak and burst are optional,
>   * thus 'average,,burst' and 'average,peak' are also legal. */
>  
> -#define VIRSH_PARSE_RATE_FIELD(index, name)                                      \
> +#define VIRSH_PARSE_RATE_FIELD(index, name)                                    \
>      do {                                                                       \
>          if (index < ntok &&                                                    \
>              *tok[index] != '\0' &&                                             \
[...]
> @@ -9096,7 +9096,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
>          return false;
>  
>  #define PARSE_MEMTUNE_PARAM(NAME, FIELD)                                    \
> -    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {            \
> +    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {          \
>          vshError(ctl, _("Unable to parse integer parameter %s"), NAME);     \
>          goto cleanup;                                                       \
>      }                                                                       \

As an aside, I'd really like if we could stop trying to be cute by
right-aligning backslashes, thus making silly adjustments like the
above wholly unnecessary.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Define multi line macros properly
Posted by Peter Krempa 6 years, 5 months ago
On Tue, Oct 31, 2017 at 13:37:55 +0100, Andrea Bolognani wrote:
> On Tue, 2017-10-31 at 12:39 +0100, Michal Privoznik wrote:
> > @@ -781,7 +781,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
> >   * 'average,peak,burst,floor', in which peak and burst are optional,
> >   * thus 'average,,burst' and 'average,peak' are also legal. */
> >  
> > -#define VIRSH_PARSE_RATE_FIELD(index, name)                                      \
> > +#define VIRSH_PARSE_RATE_FIELD(index, name)                                    \
> >      do {                                                                       \
> >          if (index < ntok &&                                                    \
> >              *tok[index] != '\0' &&                                             \
> [...]
> > @@ -9096,7 +9096,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
> >          return false;
> >  
> >  #define PARSE_MEMTUNE_PARAM(NAME, FIELD)                                    \
> > -    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {            \
> > +    if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) {          \
> >          vshError(ctl, _("Unable to parse integer parameter %s"), NAME);     \
> >          goto cleanup;                                                       \
> >      }                                                                       \
> 
> As an aside, I'd really like if we could stop trying to be cute by
> right-aligning backslashes, thus making silly adjustments like the
> above wholly unnecessary.

You'll need to come up with a syntax-check rule. Otherwise attempting to
change that will be futile.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list