sway/config: Use "!ptr" for comparison to NULL

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
This commit is contained in:
Elyes HAOUAS 2021-04-13 10:31:06 +02:00
parent dc84d9b8e8
commit 4a533f73d8
5 changed files with 15 additions and 15 deletions

View file

@ -359,7 +359,7 @@ static char *get_config_path(void) {
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
const char *config_home = getenv("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == '\0') {
if (!config_home || config_home[0] == '\0') {
config_home = config_home_fallback;
}
@ -396,7 +396,7 @@ static char *get_config_path(void) {
static bool load_config(const char *path, struct sway_config *config,
struct swaynag_instance *swaynag) {
if (path == NULL) {
if (!path) {
sway_log(SWAY_ERROR, "Unable to find a config file!");
return false;
}
@ -432,13 +432,13 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
} else {
path = get_config_path();
}
if (path == NULL) {
if (!path) {
sway_log(SWAY_ERROR, "Cannot find config file");
return false;
}
char *real_path = realpath(path, NULL);
if (real_path == NULL) {
if (!real_path) {
sway_log(SWAY_ERROR, "%s not found", path);
free(path);
return false;
@ -596,7 +596,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
char *real_path = realpath(full_path, NULL);
free(full_path);
if (real_path == NULL) {
if (!real_path) {
sway_log(SWAY_DEBUG, "%s not found.", path);
return false;
}
@ -771,7 +771,7 @@ bool read_config(FILE *file, struct sway_config *config,
bool reading_main_config = false;
char *this_config = NULL;
size_t config_size = 0;
if (config->current_config == NULL) {
if (!config->current_config) {
reading_main_config = true;
int ret_seek = fseek(file, 0, SEEK_END);
@ -784,7 +784,7 @@ bool read_config(FILE *file, struct sway_config *config,
rewind(file);
config->current_config = this_config = calloc(1, config_size + 1);
if (this_config == NULL) {
if (!this_config) {
sway_log(SWAY_ERROR, "Unable to allocate buffer for config contents");
return false;
}

View file

@ -200,7 +200,7 @@ static void invoke_swaybar(struct bar_config *bar) {
}
bar->client = wl_client_create(server.wl_display, sockets[0]);
if (bar->client == NULL) {
if (!bar->client) {
sway_log_errno(SWAY_ERROR, "wl_client_create failed");
return;
}

View file

@ -235,7 +235,7 @@ static bool validate_type_on_existing(struct input_config *type_wildcard,
char **error) {
for (int i = 0; i < config->input_configs->length; i++) {
struct input_config *ic = config->input_configs->items[i];
if (ic->input_type == NULL) {
if (!ic->input_type) {
continue;
}
@ -253,7 +253,7 @@ static bool validate_type_on_existing(struct input_config *type_wildcard,
static void merge_type_on_existing(struct input_config *type_wildcard) {
for (int i = 0; i < config->input_configs->length; i++) {
struct input_config *ic = config->input_configs->items[i];
if (ic->input_type == NULL) {
if (!ic->input_type) {
continue;
}

View file

@ -46,11 +46,11 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt
struct output_config *new_output_config(const char *name) {
struct output_config *oc = calloc(1, sizeof(struct output_config));
if (oc == NULL) {
if (!oc) {
return NULL;
}
oc->name = strdup(name);
if (oc->name == NULL) {
if (!oc->name) {
free(oc);
return NULL;
}
@ -256,7 +256,7 @@ static void set_mode(struct wlr_output *output, int width, int height,
best = mode;
break;
}
if (best == NULL || mode->refresh > best->refresh) {
if (!best || mode->refresh > best->refresh) {
best = mode;
}
}
@ -690,7 +690,7 @@ static bool _spawn_swaybg(char **command) {
}
config->swaybg_client = wl_client_create(server.wl_display, sockets[0]);
if (config->swaybg_client == NULL) {
if (!config->swaybg_client) {
sway_log_errno(SWAY_ERROR, "wl_client_create failed");
return false;
}

View file

@ -185,7 +185,7 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {
struct seat_config *copy_seat_config(struct seat_config *seat) {
struct seat_config *copy = new_seat_config(seat->name);
if (copy == NULL) {
if (!copy) {
return NULL;
}