diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 0c8c705a..988654d2 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -216,7 +216,7 @@ static const char *get_string(const char *identifier) { static void clear_stack(void) { for (int c = 0; c < 10; c++) { - if (stack[c].type == STACK_STR && stack[c].val.str != NULL) + if (stack[c].type == STACK_STR) free(stack[c].val.str); stack[c].identifier = NULL; stack[c].val.str = NULL; diff --git a/libi3/dpi.c b/libi3/dpi.c index a2c40319..9bb32b68 100644 --- a/libi3/dpi.c +++ b/libi3/dpi.c @@ -54,9 +54,7 @@ void init_dpi(void) { DLOG("Found Xft.dpi = %ld.\n", dpi); init_dpi_end: - if (resource != NULL) { - free(resource); - } + free(resource); if (database != NULL) { xcb_xrm_database_free(database); diff --git a/libi3/font.c b/libi3/font.c index 3dca8124..7be84ee0 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -224,9 +224,7 @@ i3Font load_font(const char *pattern, const bool fallback) { error->error_code); } } - if (error != NULL) { - free(error); - } + free(error); font.pattern = sstrdup(pattern); LOG("Using X font %s\n", pattern); @@ -275,8 +273,7 @@ void free_font(void) { case FONT_TYPE_XCB: { /* Close the font and free the info */ xcb_close_font(conn, savedFont->specific.xcb.id); - if (savedFont->specific.xcb.info) - free(savedFont->specific.xcb.info); + free(savedFont->specific.xcb.info); break; } case FONT_TYPE_PANGO: diff --git a/src/commands_parser.c b/src/commands_parser.c index 98f06659..4299c008 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -157,7 +157,7 @@ static long get_long(const char *identifier) { // TODO move to a common util static void clear_stack(void) { for (int c = 0; c < 10; c++) { - if (stack[c].type == STACK_STR && stack[c].val.str != NULL) + if (stack[c].type == STACK_STR) free(stack[c].val.str); stack[c].identifier = NULL; stack[c].val.str = NULL; diff --git a/src/config_parser.c b/src/config_parser.c index 2d3f3bb9..9f972fed 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -171,7 +171,7 @@ static long get_long(const char *identifier) { static void clear_stack(void) { for (int c = 0; c < 10; c++) { - if (stack[c].type == STACK_STR && stack[c].val.str != NULL) + if (stack[c].type == STACK_STR) free(stack[c].val.str); stack[c].identifier = NULL; stack[c].val.str = NULL; diff --git a/src/load_layout.c b/src/load_layout.c index 32da9c47..5a340d2c 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -153,8 +153,7 @@ static int json_end_map(void *ctx) { free(marks[i]); } - free(marks); - marks = NULL; + FREE(marks); num_marks = 0; } diff --git a/src/util.c b/src/util.c index a59283a8..594d2bb6 100644 --- a/src/util.c +++ b/src/util.c @@ -501,8 +501,7 @@ ssize_t slurp(const char *path, char **buf) { fclose(f); if ((ssize_t)n != stbuf.st_size) { ELOG("File \"%s\" could not be read entirely: got %zd, want %" PRIi64 "\n", path, n, (int64_t)stbuf.st_size); - free(*buf); - *buf = NULL; + FREE(*buf); return -1; } return (ssize_t)n;