[libvirt] [PATCH v3 3/9] qemu: add helper for getting guest users

John Ferlan jferlan at redhat.com
Wed Aug 28 10:57:09 UTC 2019


[...]

>> +
>> +static int getUserInfo(virTypedParameterPtr params, int nparams,
>> size_t nth,
>> +                       const char **username, const char **domain,
>> +                       unsigned long long *logintime)
>> +{
>> +    char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
>> +
>> +    snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
>> +             "user.%zu.name", nth);
>> +    if (username &&
>> +        virTypedParamsGetString(params, nparams, param_name,
>> username) < 0)
>> +        return -1;
>> +
>> +    snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
>> +             "user.%zu.domain", nth);
>> +    if (domain &&
>> +        virTypedParamsGetString(params, nparams, param_name, domain)
>> < 0)
>> +        return -1;
>> +
>> +    snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
>> +             "user.%zu.login-time", nth);
>> +    if (logintime &&
>> +        virTypedParamsGetULLong(params, nparams, param_name,
>> logintime) < 0)
>> +        return -1;
>> +
>> +    return 0;
> 
> This function can be renamed to checkUserInfo() and it can check the
> values directly. It saves us couple of more lines.
> 

Changes made to this function after review, but not posted AFAICT
neglected to check the return value of virTypedParamsGetString for
"user.%zu.domain" like the other two calls checked, so Coverity noted that.

John

>> +}
>> +
> 
> Michal
> 
> -- 
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list