From a6d761a31c49295f634dc9fe78be54ee47819352 Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Tue, 13 Apr 2021 10:32:52 +0200 Subject: [PATCH] sway: Use "!ptr" for comparison to NULL Signed-off-by: Elyes HAOUAS --- sway/decoration.c | 4 ++-- sway/ipc-json.c | 4 ++-- sway/ipc-server.c | 4 ++-- sway/swaynag.c | 4 ++-- sway/xdg_decoration.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sway/decoration.c b/sway/decoration.c index 849fa89c9..4611f9156 100644 --- a/sway/decoration.c +++ b/sway/decoration.c @@ -22,7 +22,7 @@ static void server_decoration_handle_mode(struct wl_listener *listener, wl_container_of(listener, deco, mode); struct sway_view *view = view_from_wlr_surface(deco->wlr_server_decoration->surface); - if (view == NULL || view->surface != deco->wlr_server_decoration->surface) { + if (!view || view->surface != deco->wlr_server_decoration->surface) { return; } @@ -38,7 +38,7 @@ void handle_server_decoration(struct wl_listener *listener, void *data) { struct wlr_server_decoration *wlr_deco = data; struct sway_server_decoration *deco = calloc(1, sizeof(*deco)); - if (deco == NULL) { + if (!deco) { return; } diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2c4c52a39..5a5a6caef 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -457,7 +457,7 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { if (((!tab_or_stack || container_is_floating(c)) && c->current.border != B_NORMAL) || c->pending.fullscreen_mode != FULLSCREEN_NONE || - c->pending.workspace == NULL) { + !c->pending.workspace) { deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; return; } @@ -657,7 +657,7 @@ static void focus_inactive_children_iterator(struct sway_node *node, json_object *focus = data->object; if (data->node == &root->node) { struct sway_output *output = node_get_output(node); - if (output == NULL) { + if (!output) { return; } size_t id = output->node.id; diff --git a/sway/ipc-server.c b/sway/ipc-server.c index aad9a7b5b..17a4e3fcb 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -127,7 +127,7 @@ void ipc_init(struct sway_server *server) { struct sockaddr_un *ipc_user_sockaddr(void) { struct sockaddr_un *ipc_sockaddr = malloc(sizeof(struct sockaddr_un)); - if (ipc_sockaddr == NULL) { + if (!ipc_sockaddr) { sway_abort("Can't allocate ipc_sockaddr"); } @@ -714,7 +714,7 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt { // TODO: Check if they're permitted to use these events struct json_object *request = json_tokener_parse(buf); - if (request == NULL || !json_object_is_type(request, json_type_array)) { + if (!request || !json_object_is_type(request, json_type_array)) { const char msg[] = "{\"success\": false}"; ipc_send_reply(client, payload_type, msg, strlen(msg)); sway_log(SWAY_INFO, "Failed to parse subscribe request"); diff --git a/sway/swaynag.c b/sway/swaynag.c index db5a919a1..6eff4a526 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -51,7 +51,7 @@ bool swaynag_spawn(const char *swaynag_command, } swaynag->client = wl_client_create(server.wl_display, sockets[0]); - if (swaynag->client == NULL) { + if (!swaynag->client) { sway_log_errno(SWAY_ERROR, "wl_client_create failed"); goto failed; } @@ -137,7 +137,7 @@ void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, return; } - if (swaynag->client == NULL && !swaynag_spawn(swaynag_command, swaynag)) { + if (!swaynag->client && !swaynag_spawn(swaynag_command, swaynag)) { return; } diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index e7c3ea73d..4b2f9dd24 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c @@ -32,7 +32,7 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->surface->data; struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); - if (deco == NULL) { + if (!deco) { return; }