From e4b0aae05a88b1e5bd2f986eec10f68326a0607c Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 6 Jul 2018 18:05:57 +0200 Subject: [PATCH] Replace free(val); val=NULL; with g_clear_pointer --- src/dbus.c | 6 ++---- src/option_parser.c | 3 +-- src/rules.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 2685137..20b6497 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -289,8 +289,7 @@ static notification *dbus_message_to_notification(const gchar *sender, GVariant n->transient = transient; if (actions->count < 1) { - actions_free(actions); - actions = NULL; + g_clear_pointer(&actions, actions_free); } n->actions = actions; @@ -484,8 +483,7 @@ static int dbus_get_fdn_daemon_info(GDBusConnection *connection, if (error) { /* Ignore the error, we may still be able to retrieve the PID */ - g_error_free(error); - error = NULL; + g_clear_pointer(&error, g_error_free); } else { g_variant_get(daemoninfo, "(ssss)", name, vendor, NULL, NULL); } diff --git a/src/option_parser.c b/src/option_parser.c index b95f911..465754b 100644 --- a/src/option_parser.c +++ b/src/option_parser.c @@ -66,9 +66,8 @@ void free_ini(void) g_free(sections[i].entries); g_free(sections[i].name); } - g_free(sections); + g_clear_pointer(§ions, g_free); section_count = 0; - sections = NULL; } section_t *get_section(const char *name) diff --git a/src/rules.c b/src/rules.c index 20d7d5a..92688bd 100644 --- a/src/rules.c +++ b/src/rules.c @@ -27,8 +27,7 @@ void rule_apply(rule_t *r, notification *n) if (r->new_icon) { g_free(n->icon); n->icon = g_strdup(r->new_icon); - rawimage_free(n->raw_icon); - n->raw_icon = NULL; + g_clear_pointer(&n->raw_icon, rawimage_free); } if (r->fg) { g_free(n->colors[ColFG]);