From c01f7df5e20cd04ee58b4519cff2477b4678c958 Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Tue, 13 Apr 2021 10:31:31 +0200 Subject: [PATCH] sway/desktop: Use "!ptr" for comparison to NULL Signed-off-by: Elyes HAOUAS --- sway/desktop/layer_shell.c | 10 +++++----- sway/desktop/output.c | 8 ++++---- sway/desktop/render.c | 2 +- sway/desktop/xdg_shell.c | 26 +++++++++++++------------- sway/desktop/xwayland.c | 26 +++++++++++++------------- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 197189910..7ce2f3e61 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -293,7 +293,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, layer, surface_commit); struct wlr_layer_surface_v1 *layer_surface = layer->layer_surface; struct wlr_output *wlr_output = layer_surface->output; - if (wlr_output == NULL) { + if (!wlr_output) { return; } @@ -334,11 +334,11 @@ static void unmap(struct sway_layer_surface *sway_layer) { cursor_rebase_all(); struct wlr_output *wlr_output = sway_layer->layer_surface->output; - if (wlr_output == NULL) { + if (!wlr_output) { return; } struct sway_output *output = wlr_output->data; - if (output == NULL) { + if (!output) { return; } output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, @@ -438,7 +438,7 @@ static struct sway_layer_subsurface *create_subsurface( struct sway_layer_surface *layer_surface) { struct sway_layer_subsurface *subsurface = calloc(1, sizeof(struct sway_layer_subsurface)); - if (subsurface == NULL) { + if (!subsurface) { return NULL; } @@ -550,7 +550,7 @@ static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup, enum layer_parent parent_type, void *parent) { struct sway_layer_popup *popup = calloc(1, sizeof(struct sway_layer_popup)); - if (popup == NULL) { + if (!popup) { return NULL; } diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 6d4f53423..f3ba4894c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -492,7 +492,7 @@ static bool scan_out_fullscreen_view(struct sway_output *output, } struct wlr_surface *surface = view->surface; - if (surface == NULL) { + if (!surface) { return false; } size_t n_surfaces = 0; @@ -502,7 +502,7 @@ static bool scan_out_fullscreen_view(struct sway_output *output, return false; } - if (surface->buffer == NULL) { + if (!surface->buffer) { return false; } @@ -524,14 +524,14 @@ static bool scan_out_fullscreen_view(struct sway_output *output, static int output_repaint_timer_handler(void *data) { struct sway_output *output = data; - if (output->wlr_output == NULL) { + if (!output->wlr_output) { return 0; } output->wlr_output->frame_pending = false; struct sway_workspace *workspace = output->current.active_workspace; - if (workspace == NULL) { + if (!workspace) { return 0; } diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 56936d539..d1e9c056c 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1017,7 +1017,7 @@ void output_render(struct sway_output *output, struct timespec *when, } struct sway_workspace *workspace = output->current.active_workspace; - if (workspace == NULL) { + if (!workspace) { return; } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 843ff90a0..94acf4345 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -90,7 +90,7 @@ static struct sway_xdg_popup *popup_create( struct sway_xdg_popup *popup = calloc(1, sizeof(struct sway_xdg_popup)); - if (popup == NULL) { + if (!popup) { return NULL; } view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface); @@ -131,7 +131,7 @@ static void get_constraints(struct sway_view *view, double *min_width, static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return NULL; } switch (prop) { @@ -148,14 +148,14 @@ static uint32_t configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); - if (xdg_shell_view == NULL) { + if (!xdg_shell_view) { return 0; } return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); } static void set_activated(struct sway_view *view, bool activated) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; @@ -165,7 +165,7 @@ static void set_activated(struct sway_view *view, bool activated) { } static void set_tiled(struct sway_view *view, bool tiled) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; @@ -178,7 +178,7 @@ static void set_tiled(struct sway_view *view, bool tiled) { } static void set_fullscreen(struct sway_view *view, bool fullscreen) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; @@ -186,7 +186,7 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { } static void set_resizing(struct sway_view *view, bool resizing) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; @@ -204,7 +204,7 @@ static bool wants_floating(struct sway_view *view) { static void for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } wlr_xdg_surface_for_each_surface(view->wlr_xdg_surface, iterator, @@ -213,7 +213,7 @@ static void for_each_surface(struct sway_view *view, static void for_each_popup_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_surface, iterator, @@ -222,7 +222,7 @@ static void for_each_popup_surface(struct sway_view *view, static bool is_transient_for(struct sway_view *child, struct sway_view *ancestor) { - if (xdg_shell_view_from_view(child) == NULL) { + if (!xdg_shell_view_from_view(child)) { return false; } struct wlr_xdg_surface *surface = child->wlr_xdg_surface; @@ -236,7 +236,7 @@ static bool is_transient_for(struct sway_view *child, } static void _close(struct sway_view *view) { - if (xdg_shell_view_from_view(view) == NULL) { + if (!xdg_shell_view_from_view(view)) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; @@ -256,7 +256,7 @@ static void close_popups(struct sway_view *view) { static void destroy(struct sway_view *view) { struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); - if (xdg_shell_view == NULL) { + if (!xdg_shell_view) { return; } free(xdg_shell_view); @@ -494,7 +494,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, destroy); struct sway_view *view = &xdg_shell_view->view; - if (!sway_assert(view->surface == NULL, "Tried to destroy a mapped view")) { + if (!sway_assert(!view->surface, "Tried to destroy a mapped view")) { return; } wl_list_remove(&xdg_shell_view->destroy.link); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 66cb3b026..b0ed07fa2 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -158,7 +158,7 @@ static struct sway_xwayland_unmanaged *create_unmanaged( struct wlr_xwayland_surface *xsurface) { struct sway_xwayland_unmanaged *surface = calloc(1, sizeof(struct sway_xwayland_unmanaged)); - if (surface == NULL) { + if (!surface) { sway_log(SWAY_ERROR, "Allocation failed"); return NULL; } @@ -190,7 +190,7 @@ static struct sway_xwayland_view *xwayland_view_from_view( } static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return NULL; } switch (prop) { @@ -208,7 +208,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p } static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return 0; } switch (prop) { @@ -232,7 +232,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { static uint32_t configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); - if (xwayland_view == NULL) { + if (!xwayland_view) { return 0; } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; @@ -244,7 +244,7 @@ static uint32_t configure(struct sway_view *view, double lx, double ly, int widt } static void set_activated(struct sway_view *view, bool activated) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; @@ -257,7 +257,7 @@ static void set_activated(struct sway_view *view, bool activated) { } static void set_tiled(struct sway_view *view, bool tiled) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; @@ -265,7 +265,7 @@ static void set_tiled(struct sway_view *view, bool tiled) { } static void set_fullscreen(struct sway_view *view, bool fullscreen) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; @@ -273,7 +273,7 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { } static bool wants_floating(struct sway_view *view) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return false; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; @@ -316,7 +316,7 @@ static void handle_set_decorations(struct wl_listener *listener, void *data) { static bool is_transient_for(struct sway_view *child, struct sway_view *ancestor) { - if (xwayland_view_from_view(child) == NULL) { + if (!xwayland_view_from_view(child)) { return false; } struct wlr_xwayland_surface *surface = child->wlr_xwayland_surface; @@ -330,7 +330,7 @@ static bool is_transient_for(struct sway_view *child, } static void _close(struct sway_view *view) { - if (xwayland_view_from_view(view) == NULL) { + if (!xwayland_view_from_view(view)) { return; } wlr_xwayland_surface_close(view->wlr_xwayland_surface); @@ -338,7 +338,7 @@ static void _close(struct sway_view *view) { static void destroy(struct sway_view *view) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); - if (xwayland_view == NULL) { + if (!xwayland_view) { return; } free(xwayland_view); @@ -349,7 +349,7 @@ static void get_constraints(struct sway_view *view, double *min_width, struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints; - if (size_hints == NULL) { + if (!size_hints) { *min_width = DBL_MIN; *max_width = DBL_MAX; *min_height = DBL_MIN; @@ -787,7 +787,7 @@ void handle_xwayland_ready(struct wl_listener *listener, void *data) { xcb_generic_error_t *error = NULL; xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_conn, cookies[i], &error); - if (reply != NULL && error == NULL) { + if (reply != NULL && !error) { xwayland->atoms[i] = reply->atom; } free(reply);