[libvirt] [PATCH 3/4] virchrdev: Use more g_autofree and VIR_AUTOCLOSE

Erik Skultety eskultet at redhat.com
Thu Jan 16 13:02:09 UTC 2020


...

> @@ -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.

With your assurance of the above:
Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list