From ee8589ec9d3a7cb3d67f5871a333741d85d1b589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 28 Jan 2020 19:02:40 +0100 Subject: [PATCH] main: Ensure we always free context, loop and error In case of early return we may not free them consistently, while this is not a big problem in a main function, is better to have a cleaner management, and we did get valgrind reports. --- src/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 1a669fc..2c62c04 100644 --- a/src/main.c +++ b/src/main.c @@ -140,9 +140,9 @@ static gboolean sigterm_callback(gpointer data) int main(int argc, char **argv) { - GOptionContext *context; - GMainLoop *loop; - GError *error = NULL; + g_autoptr(GOptionContext) context = NULL; + g_autoptr(GMainLoop) loop = NULL; + g_autoptr(GError) error = NULL; FprintManager *manager; DBusGProxy *driver_proxy; guint32 request_name_ret; @@ -158,7 +158,6 @@ int main(int argc, char **argv) if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_warning ("couldn't parse command-line options: %s\n", error->message); - g_error_free (error); return 1; }