From c66fb38bf85f14266924ca47b8147eaba7b660bd Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Tue, 13 Apr 2021 10:29:24 +0200 Subject: [PATCH] common: Use "!ptr" for comparison to NULL Signed-off-by: Elyes HAOUAS --- common/list.c | 2 +- common/pango.c | 4 ++-- common/stringop.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/list.c b/common/list.c index c3e2fe204..5cb145ea7 100644 --- a/common/list.c +++ b/common/list.c @@ -23,7 +23,7 @@ static void list_resize(list_t *list) { } void list_free(list_t *list) { - if (list == NULL) { + if (!list) { return; } free(list->items); diff --git a/common/pango.c b/common/pango.c index fc3d06886..26335fd57 100644 --- a/common/pango.c +++ b/common/pango.c @@ -91,7 +91,7 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, va_end(args); char *buf = malloc(length); - if (buf == NULL) { + if (!buf) { sway_log(SWAY_ERROR, "Failed to allocate memory"); return; } @@ -118,7 +118,7 @@ void pango_printf(cairo_t *cairo, const char *font, va_end(args); char *buf = malloc(length); - if (buf == NULL) { + if (!buf) { sway_log(SWAY_ERROR, "Failed to allocate memory"); return; } diff --git a/common/stringop.c b/common/stringop.c index 7fb3fe12a..776538bb5 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -319,7 +319,7 @@ bool expand_path(char **path) { memmove(ptr + 1, ptr, strlen(ptr) + 1); *ptr = '\\'; } - if (wordexp(*path, &p, 0) != 0 || p.we_wordv[0] == NULL) { + if (wordexp(*path, &p, 0) != 0 || !p.we_wordv[0]) { wordfree(&p); return false; }