[libvirt PATCH 6/9] esx: reorder code to avoid need to VIR_FREE mimeType

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

 



mimeType is initialized to NULL, and then only set in one place, just
before a check (not involving mimeType) that then VIR_FREEs mimeType
if it fails. If we just reorder the code to do the check prior to
setting mimeType, then there won't be any need to VIR_FREE(mimeType)
on failure (because it will already be empty/NULL).

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 src/esx/esx_driver.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 47873c0d54..2d010096a5 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2374,12 +2374,10 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
 
     url = virBufferContentAndReset(&buffer);
 
-    mimeType = g_strdup("image/png");
-
-    if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) {
-        VIR_FREE(mimeType);
+    if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0)
         goto cleanup;
-    }
+
+    mimeType = g_strdup("image/png");
 
  cleanup:
 
-- 
2.29.2




[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