On a Friday in 2021, Michal Prívozník wrote:
On 9/24/21 1:25 AM, Kristina Hanicova wrote:
> Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
> ---
> tools/virsh-domain.c | 99 +++++++++++++++++++++-----------------------
> 1 file changed, 47 insertions(+), 52 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index f876f30cc5..b64df640ba 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -5157,7 +5157,6 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
> int nparams = 0;
> int nupdates = 0;
> size_t i;
> - int ret;
> bool ret_val = false;
> unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
> bool current = vshCommandOptBool(cmd, "current");
> @@ -5176,73 +5175,69 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
> return false;
>
> /* Print SchedulerType */
> - schedulertype = virDomainGetSchedulerType(dom, &nparams);
> - if (schedulertype != NULL) {
> - vshPrint(ctl, "%-15s: %s\n", _("Scheduler"),
schedulertype);
> - VIR_FREE(schedulertype);
> - } else {
> + if (!(schedulertype = virDomainGetSchedulerType(dom, &nparams))) {
> vshPrint(ctl, "%-15s: %s\n", _("Scheduler"),
_("Unknown"));
> goto cleanup;
> }
>
> - if (nparams) {
> - params = g_new0(virTypedParameter, nparams);
> + vshPrint(ctl, "%-15s: %s\n", _("Scheduler"),
schedulertype);
> + VIR_FREE(schedulertype);
I think instead of adding this VIR_FREE() you can just mark the variable
as g_autofree. It's a negligible change compared how much lines are
being changed.
Which sounds like a good reason not to mix it with the code movement.
Jano