qemu: Bring if() outside from loop in virDomainFSInfoFormat()

After previous commit, the freeing of @info_ret inside of
virDomainFSInfoFormat() looks like this:

  for () {
    if (info_ret)
      virDomainFSInfoFree(info_ret[i]);
  }

It is needless to compare @info_ret against NULL in each
iteration. We can switch the order and do the comparison first
followed by the loop.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2021-02-15 17:19:10 +01:00
parent 59c80e9fd0
commit 9ad1e1d897

View File

@ -18977,13 +18977,14 @@ virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
ret = nagentinfo; ret = nagentinfo;
cleanup: cleanup:
for (i = 0; i < nagentinfo; i++) { if (info_ret) {
/* if there was an error, free any memory we've allocated for the for (i = 0; i < nagentinfo; i++) {
* return value */ /* if there was an error, free any memory we've allocated for the
if (info_ret) * return value */
virDomainFSInfoFree(info_ret[i]); virDomainFSInfoFree(info_ret[i]);
}
g_free(info_ret);
} }
g_free(info_ret);
return ret; return ret;
} }