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(a)redhat.com>
Thanks,
Michal