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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


Thanks,
Michal




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux