[virt-tools-list] [PATCH virt-viewer 1/2] Clear GError in cleanup section

Pavel Grunt pgrunt at redhat.com
Fri Mar 20 09:35:55 UTC 2015


---
Depends on https://www.redhat.com/archives/virt-tools-list/2015-March/msg00120.html
---
 src/remote-viewer-main.c | 3 +--
 src/virt-viewer-main.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
index b3bb053..1bb61c7 100644
--- a/src/remote-viewer-main.c
+++ b/src/remote-viewer-main.c
@@ -134,7 +134,6 @@ main(int argc, char **argv)
         g_printerr(_("%s\nRun '%s --help' to see a full list of available command line options\n"),
                    error->message, base_name);
         g_free(base_name);
-        g_error_free(error);
         goto cleanup;
     }
 
@@ -177,7 +176,6 @@ main(int argc, char **argv)
     if (!virt_viewer_app_start(app, &error)) {
         if (g_error_matches(error, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED))
             ret = 0;
-        g_clear_error(&error);
         goto cleanup;
     }
 
@@ -193,6 +191,7 @@ main(int argc, char **argv)
     if (viewer)
         g_object_unref(viewer);
     g_strfreev(args);
+    g_clear_error(&error);
 
     return ret;
 }
diff --git a/src/virt-viewer-main.c b/src/virt-viewer-main.c
index ae880ab..f3d6b35 100644
--- a/src/virt-viewer-main.c
+++ b/src/virt-viewer-main.c
@@ -98,7 +98,6 @@ int main(int argc, char **argv)
     if (error) {
         g_printerr("%s\n%s\n",
                    error->message, help_msg);
-        g_error_free(error);
         goto cleanup;
     }
 
@@ -116,7 +115,6 @@ int main(int argc, char **argv)
     if (!virt_viewer_app_start(VIRT_VIEWER_APP(viewer), &error)) {
         if (g_error_matches(error, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED))
             ret = 0;
-        g_clear_error(&error);
         goto cleanup;
     }
 
@@ -130,6 +128,7 @@ int main(int argc, char **argv)
     g_free(uri);
     g_strfreev(args);
     g_free(help_msg);
+    g_clear_error(&error);
 
     return ret;
 }
-- 
2.3.3




More information about the virt-tools-list mailing list