[PATCH v2 1/6] virsh: domain: refactor cmdSchedinfo()

Ján Tomko jtomko at redhat.com
Fri Sep 24 10:28:17 UTC 2021


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210924/259b137b/attachment-0001.sig>


More information about the libvir-list mailing list