From dda0ed1d00ee28b5f4b7f6a15722211133f56603 Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Wed, 18 Oct 2017 10:32:07 +0200 Subject: [PATCH] Fix assignment reported by clang --- panel-plugin/notification-plugin-log.c | 12 +++++++++--- xfce4-notifyd-config/main.c | 19 +++++++++++++++---- xfce4-notifyd/xfce-notify-daemon.c | 6 +++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c index dcc7456..caa3aaa 100644 --- a/panel-plugin/notification-plugin-log.c +++ b/panel-plugin/notification-plugin-log.c @@ -144,7 +144,7 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin) const char *tooltip_format_simple = "\%s - \%s"; char *markup; gchar *app_name; - gchar *tooltip_timestamp; + gchar *tooltip_timestamp = NULL; gchar *tmp; GTimeVal tv; GDateTime *log_timestamp; @@ -158,7 +158,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS if (g_time_val_from_iso8601 (group, &tv) == TRUE) { - if (log_timestamp = g_date_time_new_from_timeval_local (&tv)) { + log_timestamp = g_date_time_new_from_timeval_local (&tv); + if (log_timestamp != NULL) { tooltip_timestamp = g_date_time_format (log_timestamp, "%c"); g_date_time_unref(log_timestamp); } @@ -222,7 +223,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS tmp = g_key_file_get_string (notify_log, group, "body", NULL); if (g_strcmp0 (tmp, "") == 0) { gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 2); - markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp); + if (tooltip_timestamp != NULL) { + markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp); + } + else { + markup = g_strdup_printf (format, app_name); + } } else { gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 1); diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c index cb9d204..77605b6 100644 --- a/xfce4-notifyd-config/main.c +++ b/xfce4-notifyd-config/main.c @@ -572,13 +572,14 @@ xfce4_notifyd_log_populate (NotificationLogWidgets *log_widgets) const char *tooltip_format_simple = "\%s - \%s"; char *markup; gchar *app_name; - gchar *tooltip_timestamp; + gchar *tooltip_timestamp = NULL; gchar *tmp; GTimeVal tv; GDateTime *log_timestamp; if (g_time_val_from_iso8601 (group, &tv) == TRUE) { - if (log_timestamp = g_date_time_new_from_timeval_local (&tv)) { + log_timestamp = g_date_time_new_from_timeval_local (&tv); + if (log_timestamp != NULL) { tooltip_timestamp = g_date_time_format (log_timestamp, "%c"); g_date_time_unref(log_timestamp); } @@ -651,12 +652,22 @@ xfce4_notifyd_log_populate (NotificationLogWidgets *log_widgets) tmp = g_key_file_get_string (notify_log, group, "body", NULL); if (g_strcmp0 (tmp, "") == 0) { gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 2); - markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp); + if (tooltip_timestamp != NULL) { + markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp); + } + else { + markup = g_strdup_printf (format, app_name); + } } else { gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (body), 1, 1, 1, 1); - markup = g_strdup_printf (tooltip_format, app_name, tooltip_timestamp, tmp); + if (tooltip_timestamp != NULL) { + markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp); + } + else { + markup = g_strdup_printf (format, app_name); + } } g_free (tmp); g_free (app_name); diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c index e5ff963..c8e62be 100644 --- a/xfce4-notifyd/xfce-notify-daemon.c +++ b/xfce4-notifyd/xfce-notify-daemon.c @@ -1250,12 +1250,12 @@ notify_notify (XfceNotifyGBus *skeleton, if (xndaemon->notification_log == TRUE && transient == FALSE) { /* Either log in DND mode or always for muted apps */ - if (xndaemon->log_level == 0 && xndaemon->do_not_disturb == TRUE || + if ((xndaemon->log_level == 0 && xndaemon->do_not_disturb == TRUE) || xndaemon->log_level == 1) /* Log either all, all except muted or only muted applications */ if (xndaemon->log_level_apps == 0 || - xndaemon->log_level_apps == 1 && application_is_muted == FALSE || - xndaemon->log_level_apps == 2 && application_is_muted == TRUE) + (xndaemon->log_level_apps == 1 && application_is_muted == FALSE) || + (xndaemon->log_level_apps == 2 && application_is_muted == TRUE)) xfce_notify_log_insert (new_app_name, summary, body, image_data, image_path, app_icon, desktop_id, expire_timeout, actions); -- 2.13.6