From c6d783f5e2d1416b77707f43ba0aca083582a14d Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Sun, 1 Jan 2017 17:13:35 +0200 Subject: [PATCH] Replace null checks with assert calls In my opinion, it's better to crash early when something is wrong than to pretend it never happened. This change will allow us to catch more in the long run. --- src/notification.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/notification.c b/src/notification.c index a1e68ec..f14f080 100644 --- a/src/notification.c +++ b/src/notification.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "dbus.h" #include "x.h" @@ -157,8 +158,7 @@ int notification_is_duplicate(const notification *a, const notification *b) */ void notification_free(notification * n) { - if (n == NULL) - return; + assert(n != NULL); free(n->appname); free(n->summary); free(n->body); @@ -332,8 +332,7 @@ notification *notification_create(void) */ int notification_init(notification * n, int id) { - if (n == NULL) - return -1; + assert(n != NULL); if (strcmp("DUNST_COMMAND_PAUSE", n->summary) == 0) { pause_display = true; @@ -569,8 +568,7 @@ int notification_close_by_id(int id, int reason) */ int notification_close(notification * n, int reason) { - if (n == NULL) - return -1; + assert(n != NULL); return notification_close_by_id(n->id, reason); }