From 0cb1524cc6b02322ba6120babece3bb18eb0e709 Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Sun, 1 Jan 2017 17:05:25 +0200 Subject: [PATCH] Don't check return status of notification_create notification_create is guaranteed to return a pointer to a notification, if the memory allocation fails it throws an error and exits the program. --- src/dbus.c | 3 --- src/dunst.c | 3 --- src/notification.c | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index baa37c9..2d0f53c 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -296,9 +296,6 @@ static void on_notify(GDBusConnection * connection, } notification *n = notification_create(); - if(n == NULL) { - die("Unable to allocate memory", EXIT_FAILURE); - } n->appname = appname; n->summary = summary; n->body = body; diff --git a/src/dunst.c b/src/dunst.c index 7109064..241524c 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -344,9 +344,6 @@ int dunst_main(int argc, char *argv[]) if (settings.startup_notification) { notification *n = notification_create(); - if(n == NULL) { - die("Unable to allocate memory", EXIT_FAILURE); - } n->appname = strdup("dunst"); n->summary = strdup("startup"); n->body = strdup("dunst is up and running"); diff --git a/src/notification.c b/src/notification.c index b3c956f..a1e68ec 100644 --- a/src/notification.c +++ b/src/notification.c @@ -321,6 +321,7 @@ char *notification_extract_markup_urls(char **str_ptr) { notification *notification_create(void) { notification *n = malloc(sizeof(notification)); + if(n == NULL) die("Unable to allocate memory", EXIT_FAILURE); memset(n, 0, sizeof(notification)); return n; }