sway/tree: 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:17 +02:00
parent 99634bf396
commit 840d759956
2 changed files with 12 additions and 12 deletions

View file

@ -44,14 +44,14 @@ void view_init(struct sway_view *view, enum sway_view_type type,
} }
void view_destroy(struct sway_view *view) { void view_destroy(struct sway_view *view) {
if (!sway_assert(view->surface == NULL, "Tried to free mapped view")) { if (!sway_assert(!view->surface, "Tried to free mapped view")) {
return; return;
} }
if (!sway_assert(view->destroying, if (!sway_assert(view->destroying,
"Tried to free view which wasn't marked as destroying")) { "Tried to free view which wasn't marked as destroying")) {
return; return;
} }
if (!sway_assert(view->container == NULL, if (!sway_assert(!view->container,
"Tried to free view which still has a container " "Tried to free view which still has a container "
"(might have a pending transaction?)")) { "(might have a pending transaction?)")) {
return; return;
@ -71,7 +71,7 @@ void view_destroy(struct sway_view *view) {
} }
void view_begin_destroy(struct sway_view *view) { void view_begin_destroy(struct sway_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; return;
} }
view->destroying = true; view->destroying = true;
@ -700,7 +700,7 @@ static void handle_foreign_destroy(
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool fullscreen, struct wlr_output *fullscreen_output, bool fullscreen, struct wlr_output *fullscreen_output,
bool decoration) { bool decoration) {
if (!sway_assert(view->surface == NULL, "cannot map mapped view")) { if (!sway_assert(!view->surface, "cannot map mapped view")) {
return; return;
} }
view->surface = wlr_surface; view->surface = wlr_surface;
@ -910,7 +910,7 @@ static void subsurface_get_root_coords(struct sway_view_child *child,
while (surface && wlr_surface_is_subsurface(surface)) { while (surface && wlr_surface_is_subsurface(surface)) {
struct wlr_subsurface *subsurface = struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface); wlr_subsurface_from_wlr_surface(surface);
if (subsurface == NULL) { if (!subsurface) {
break; break;
} }
*root_sx += subsurface->current.x; *root_sx += subsurface->current.x;
@ -949,7 +949,7 @@ static void view_subsurface_create(struct sway_view *view,
struct wlr_subsurface *wlr_subsurface) { struct wlr_subsurface *wlr_subsurface) {
struct sway_subsurface *subsurface = struct sway_subsurface *subsurface =
calloc(1, sizeof(struct sway_subsurface)); calloc(1, sizeof(struct sway_subsurface));
if (subsurface == NULL) { if (!subsurface) {
sway_log(SWAY_ERROR, "Allocation failed"); sway_log(SWAY_ERROR, "Allocation failed");
return; return;
} }
@ -968,7 +968,7 @@ static void view_child_subsurface_create(struct sway_view_child *child,
struct wlr_subsurface *wlr_subsurface) { struct wlr_subsurface *wlr_subsurface) {
struct sway_subsurface *subsurface = struct sway_subsurface *subsurface =
calloc(1, sizeof(struct sway_subsurface)); calloc(1, sizeof(struct sway_subsurface));
if (subsurface == NULL) { if (!subsurface) {
sway_log(SWAY_ERROR, "Allocation failed"); sway_log(SWAY_ERROR, "Allocation failed");
return; return;
} }
@ -1139,7 +1139,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
if (wlr_surface_is_xdg_surface(wlr_surface)) { if (wlr_surface_is_xdg_surface(wlr_surface)) {
struct wlr_xdg_surface *xdg_surface = struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_from_wlr_surface(wlr_surface); wlr_xdg_surface_from_wlr_surface(wlr_surface);
if (xdg_surface == NULL) { if (!xdg_surface) {
return NULL; return NULL;
} }
return view_from_wlr_xdg_surface(xdg_surface); return view_from_wlr_xdg_surface(xdg_surface);
@ -1148,7 +1148,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
if (wlr_surface_is_xwayland_surface(wlr_surface)) { if (wlr_surface_is_xwayland_surface(wlr_surface)) {
struct wlr_xwayland_surface *xsurface = struct wlr_xwayland_surface *xsurface =
wlr_xwayland_surface_from_wlr_surface(wlr_surface); wlr_xwayland_surface_from_wlr_surface(wlr_surface);
if (xsurface == NULL) { if (!xsurface) {
return NULL; return NULL;
} }
return view_from_wlr_xwayland_surface(xsurface); return view_from_wlr_xwayland_surface(xsurface);
@ -1157,7 +1157,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
if (wlr_surface_is_subsurface(wlr_surface)) { if (wlr_surface_is_subsurface(wlr_surface)) {
struct wlr_subsurface *subsurface = struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(wlr_surface); wlr_subsurface_from_wlr_surface(wlr_surface);
if (subsurface == NULL) { if (!subsurface) {
return NULL; return NULL;
} }
return view_from_wlr_surface(subsurface->parent); return view_from_wlr_surface(subsurface->parent);

View file

@ -56,7 +56,7 @@ struct sway_output *workspace_get_initial_output(const char *name) {
struct sway_workspace *workspace_create(struct sway_output *output, struct sway_workspace *workspace_create(struct sway_output *output,
const char *name) { const char *name) {
if (output == NULL) { if (!output) {
output = workspace_get_initial_output(name); output = workspace_get_initial_output(name);
} }
@ -584,7 +584,7 @@ bool workspace_switch(struct sway_workspace *workspace,
sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", sway_log(SWAY_DEBUG, "Switching to workspace %p:%s",
workspace, workspace->name); workspace, workspace->name);
struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node); struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node);
if (next == NULL) { if (!next) {
next = &workspace->node; next = &workspace->node;
} }
seat_set_focus(seat, next); seat_set_focus(seat, next);