[libvirt] [PATCH 05/23] qemu_conf: split out virQEMUDriverConfigLoadSWTPMEntry

Ján Tomko jtomko at redhat.com
Fri Jan 18 11:56:23 UTC 2019


On Thu, Jan 17, 2019 at 08:03:44AM -0500, John Ferlan wrote:
>
>
>On 1/15/19 8:23 AM, Ján Tomko wrote:
>> Split out parts of the config parsing code to make
>> the parent function easier to read.
>>
>> Signed-off-by: Ján Tomko <jtomko at redhat.com>
>> ---
>>  src/qemu/qemu_conf.c | 36 +++++++++++++++++++++++++-----------
>>  1 file changed, 25 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
>> index 837bff6b30..325e5ccfd5 100644
>> --- a/src/qemu/qemu_conf.c
>> +++ b/src/qemu/qemu_conf.c
>> @@ -423,6 +423,30 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
>>  }
>>
>>
>> +static int
>> +virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg,
>> +                                  virConfPtr conf)
>> +{
>> +    char *swtpm_user = NULL, *swtpm_group = NULL;
>
>Some would note these should be on separate lines, but I'll note that
>since we have it, these should be:
>
>    VIR_AUTOPTR(char *) swtpm_user = NULL;
>    VIR_AUTOPTR(char *) swtpm_group = NULL;
>
>> +    int ret = -1;
>> +
>> +    if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0)
>> +        goto cleanup;
>> +    if (swtpm_user && virGetUserID(swtpm_user, &cfg->swtpm_user) < 0)
>> +        goto cleanup;
>> +
>> +    if (virConfGetValueString(conf, "swtpm_group", &swtpm_group) < 0)
>> +        goto cleanup;
>> +    if (swtpm_group && virGetGroupID(swtpm_group, &cfg->swtpm_group) < 0)
>> +        goto cleanup;
>> +
>> +    ret = 0;
>> + cleanup:
>> +    VIR_FREE(swtpm_user);
>> +    VIR_FREE(swtpm_group);
>
>Thus freeing you of needing this and perhaps changing your logic above.
>
>I "understand" the "norm" is to just purely copy and then have another
>patch, but I really believe in this case it's so obvious that a separate
>patch isn't required especially since VIR_AUTOFREE is more commonly used.
>

Yes, I'd rather not include any functional changes here (other than
those necessary to deal with the (lack of a) cleanup section.

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/20190118/80ae9c13/attachment-0001.sig>


More information about the libvir-list mailing list