sway: 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:32:52 +02:00
parent 840d759956
commit a6d761a31c
5 changed files with 9 additions and 9 deletions

View file

@ -22,7 +22,7 @@ static void server_decoration_handle_mode(struct wl_listener *listener,
wl_container_of(listener, deco, mode); wl_container_of(listener, deco, mode);
struct sway_view *view = struct sway_view *view =
view_from_wlr_surface(deco->wlr_server_decoration->surface); 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; return;
} }
@ -38,7 +38,7 @@ void handle_server_decoration(struct wl_listener *listener, void *data) {
struct wlr_server_decoration *wlr_deco = data; struct wlr_server_decoration *wlr_deco = data;
struct sway_server_decoration *deco = calloc(1, sizeof(*deco)); struct sway_server_decoration *deco = calloc(1, sizeof(*deco));
if (deco == NULL) { if (!deco) {
return; return;
} }

View file

@ -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)) && if (((!tab_or_stack || container_is_floating(c)) &&
c->current.border != B_NORMAL) || c->current.border != B_NORMAL) ||
c->pending.fullscreen_mode != FULLSCREEN_NONE || 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; deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0;
return; return;
} }
@ -657,7 +657,7 @@ static void focus_inactive_children_iterator(struct sway_node *node,
json_object *focus = data->object; json_object *focus = data->object;
if (data->node == &root->node) { if (data->node == &root->node) {
struct sway_output *output = node_get_output(node); struct sway_output *output = node_get_output(node);
if (output == NULL) { if (!output) {
return; return;
} }
size_t id = output->node.id; size_t id = output->node.id;

View file

@ -127,7 +127,7 @@ void ipc_init(struct sway_server *server) {
struct sockaddr_un *ipc_user_sockaddr(void) { struct sockaddr_un *ipc_user_sockaddr(void) {
struct sockaddr_un *ipc_sockaddr = malloc(sizeof(struct sockaddr_un)); struct sockaddr_un *ipc_sockaddr = malloc(sizeof(struct sockaddr_un));
if (ipc_sockaddr == NULL) { if (!ipc_sockaddr) {
sway_abort("Can't allocate 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 // TODO: Check if they're permitted to use these events
struct json_object *request = json_tokener_parse(buf); 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}"; const char msg[] = "{\"success\": false}";
ipc_send_reply(client, payload_type, msg, strlen(msg)); ipc_send_reply(client, payload_type, msg, strlen(msg));
sway_log(SWAY_INFO, "Failed to parse subscribe request"); sway_log(SWAY_INFO, "Failed to parse subscribe request");

View file

@ -51,7 +51,7 @@ bool swaynag_spawn(const char *swaynag_command,
} }
swaynag->client = wl_client_create(server.wl_display, sockets[0]); 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"); sway_log_errno(SWAY_ERROR, "wl_client_create failed");
goto failed; goto failed;
} }
@ -137,7 +137,7 @@ void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
return; return;
} }
if (swaynag->client == NULL && !swaynag_spawn(swaynag_command, swaynag)) { if (!swaynag->client && !swaynag_spawn(swaynag_command, swaynag)) {
return; return;
} }

View file

@ -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_shell_view *xdg_shell_view = wlr_deco->surface->data;
struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco));
if (deco == NULL) { if (!deco) {
return; return;
} }