Decrease scope of some variables

There are couple of variables that are declared at function
beginning but then used solely within a block (either for() loop
or if() statement). And just before their use they are zeroed
explicitly using memset(). Decrease their scope, use struct zero
initializer and drop explicit memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
This commit is contained in:
Michal Privoznik
2023-08-02 15:30:04 +02:00
parent 6b4ce69251
commit 039b16e41e
8 changed files with 15 additions and 28 deletions

View File

@@ -444,7 +444,6 @@ cmdDomblkinfoGet(const virDomainBlockInfo *info,
static bool
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainBlockInfo info;
g_autoptr(virshDomain) dom = NULL;
bool human = false;
bool all = false;
@@ -491,6 +490,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
g_autofree char *cap = NULL;
g_autofree char *alloc = NULL;
g_autofree char *phy = NULL;
virDomainBlockInfo info = { 0 };
ctxt->node = disks[i];
protocol = virXPathString("string(./source/@protocol)", ctxt);
@@ -513,10 +513,6 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
return false;
}
}
} else {
/* if we don't call virDomainGetBlockInfo() who clears 'info'
* we have to do it manually */
memset(&info, 0, sizeof(info));
}
if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human))
@@ -531,6 +527,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
g_autofree char *cap = NULL;
g_autofree char *alloc = NULL;
g_autofree char *phy = NULL;
virDomainBlockInfo info = { 0 };
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0)
return false;