]> xenbits.xensource.com Git - libvirt.git/commitdiff
tools: Fix vshControl declaration and initialization
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Aug 2023 12:57:44 +0000 (14:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Aug 2023 14:30:56 +0000 (16:30 +0200)
Both virsh and virt-admin have vshControl typed variables and
also pointers to these variables. In both cases these are
declared on a single line. Do the following:

  1) break declaration into two lines,
  2) use struct zero initializer for vshControl and
     virshControl/vshAdmControl structs,
  3) drop explicit memset(.., 0, ...) ;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
tools/virsh.c
tools/virt-admin.c

index 963e886860a261740660f9f9d703ee8898f25058..40c23e41801c03c13b5dbb5b66e4d1a82db924b3 100644 (file)
@@ -831,12 +831,11 @@ static const vshClientHooks hooks = {
 int
 main(int argc, char **argv)
 {
-    vshControl _ctl, *ctl = &_ctl;
-    virshControl virshCtl;
+    vshControl _ctl = { 0 };
+    vshControl *ctl = &_ctl;
+    virshControl virshCtl = { 0 };
     bool ret = true;
 
-    memset(ctl, 0, sizeof(vshControl));
-    memset(&virshCtl, 0, sizeof(virshControl));
     ctl->name = "virsh";        /* hardcoded name of the binary */
     ctl->env_prefix = "VIRSH";
     ctl->log_fd = -1;           /* Initialize log file descriptor */
index db246dc3a6fea6e118753f9df276b528fdb8fe12..9d01890447d3891bc278aeb8ef8850b26a030ebe 100644 (file)
@@ -1554,12 +1554,11 @@ static const vshClientHooks hooks = {
 int
 main(int argc, char **argv)
 {
-    vshControl _ctl, *ctl = &_ctl;
-    vshAdmControl virtAdminCtl;
+    vshControl _ctl = { 0 };
+    vshControl *ctl = &_ctl;
+    vshAdmControl virtAdminCtl = { 0 };
     bool ret = true;
 
-    memset(ctl, 0, sizeof(vshControl));
-    memset(&virtAdminCtl, 0, sizeof(vshAdmControl));
     ctl->name = "virt-admin";        /* hardcoded name of the binary */
     ctl->env_prefix = "VIRT_ADMIN";
     ctl->log_fd = -1;                /* Initialize log file descriptor */