[Libosinfo] [osinfo-db-tools PATCH v2 6/9] path: Use g_clear_*() functions

Fabiano Fidêncio fidencio at redhat.com
Wed Jul 3 10:14:07 UTC 2019


Let's use g_clear_object() & g_clear_error() as those two functions
avoid us checking whether the object is NULL or not and also sets the
object to NULL after unrefing it.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tools/osinfo-db-path.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/osinfo-db-path.c b/tools/osinfo-db-path.c
index 8ef7e55..cd133a3 100644
--- a/tools/osinfo-db-path.c
+++ b/tools/osinfo-db-path.c
@@ -102,9 +102,7 @@ gint main(gint argc, gchar **argv)
     ret = EXIT_SUCCESS;
 
  error:
-    if (dir) {
-        g_object_unref(dir);
-    }
+    g_clear_object(&dir);
     g_clear_error(&error);
     g_option_context_free(context);
 
-- 
2.21.0




More information about the Libosinfo mailing list