[libvirt] [PATCH 3/4] virchrdev: Use more g_autofree and VIR_AUTOCLOSE
Michal Privoznik
mprivozn at redhat.com
Thu Jan 16 13:15:49 UTC 2020
On 1/16/20 2:02 PM, Erik Skultety wrote:
> ...
>
>> @@ -184,10 +177,8 @@ static int virChrdevLockFileCreate(const char *dev)
>> */
>> static void virChrdevLockFileRemove(const char *dev)
>> {
>> - char *path = virChrdevLockFilePath(dev);
>> - if (path)
>> - unlink(path);
>> - VIR_FREE(path);
>> + g_autofree char *path = virChrdevLockFilePath(dev);
>> + unlink(path);
>
> I assume that you deleted the 'if' clause only because virChrdevLockFileRemove
> is only called from virChrdevHashEntryFree and the existence of the lockfile is
> therefore implicitly assumed? Because I'm not sure unlink can handle NULL,
> especially if it blindly calls strlen on the input.
The virChrdevLockFilePath() can return NULL on OOM. However, we would
crash on OOM, so we won't even get to unlink()
>
> With your assurance of the above:
> Reviewed-by: Erik Skultety <eskultet at redhat.com>
>
Thanks,
Michal
More information about the libvir-list
mailing list