From c63575650567d111810b6633dda08409d868d02d Mon Sep 17 00:00:00 2001 From: rbuj Date: Sat, 9 Jan 2021 14:47:06 +0100 Subject: Redundant NULL check before freeing a variable --- applets/clock/system-timezone.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'applets/clock/system-timezone.c') diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c index b1755aa9..199756e0 100644 --- a/applets/clock/system-timezone.c +++ b/applets/clock/system-timezone.c @@ -234,15 +234,8 @@ system_timezone_finalize (GObject *obj) systz = SYSTEM_TIMEZONE (obj); priv = system_timezone_get_instance_private (systz); - if (priv->tz) { - g_free (priv->tz); - priv->tz = NULL; - } - - if (priv->env_tz) { - g_free (priv->env_tz); - priv->env_tz = NULL; - } + g_free (priv->tz); + g_free (priv->env_tz); for (i = 0; i < CHECK_NB; i++) { if (priv->monitors[i]) @@ -265,9 +258,10 @@ system_timezone_monitor_changed (GFileMonitor *handle, gpointer user_data) { SystemTimezonePrivate *priv; - priv = system_timezone_get_instance_private (user_data); char *new_tz; + priv = system_timezone_get_instance_private (user_data); + if (event != G_FILE_MONITOR_EVENT_CHANGED && event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT && event != G_FILE_MONITOR_EVENT_DELETED && @@ -280,13 +274,13 @@ system_timezone_monitor_changed (GFileMonitor *handle, if (strcmp (priv->tz, new_tz) != 0) { g_free (priv->tz); - priv->tz = new_tz; + priv->tz = g_strdup (new_tz); g_signal_emit (G_OBJECT (user_data), system_timezone_signals[CHANGED], 0, priv->tz); - } else - g_free (new_tz); + } + g_free (new_tz); } @@ -413,16 +407,12 @@ system_timezone_read_key_file (const char *filename, if (value[0] == '\"') { if (value[len - 1] == '\"') { - if (retval) - g_free (retval); - + g_free (retval); retval = g_strndup (value + 1, len - 2); } } else { - if (retval) - g_free (retval); - + g_free (retval); retval = g_strdup (line + strlen (key_eq)); } -- cgit v1.2.1