From: Michal Privoznik Date: Wed, 2 Aug 2023 12:57:44 +0000 (+0200) Subject: tools: Fix vshControl declaration and initialization X-Git-Tag: v9.7.0-rc1~169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33b794898364be55f19eaf9a834cd095b75e1b71;p=thirdparty%2Flibvirt.git tools: Fix vshControl declaration and initialization 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 Reviewed-by: Claudio Fontana --- diff --git a/tools/virsh.c b/tools/virsh.c index 963e886860..40c23e4180 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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 */ diff --git a/tools/virt-admin.c b/tools/virt-admin.c index db246dc3a6..9d01890447 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -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 */