]> git.sur5r.net Git - i3/i3/commitdiff
get_output_for_con: Assert result != NULL
authorOrestis Floros <orestisf1993@gmail.com>
Thu, 21 Mar 2019 21:51:57 +0000 (23:51 +0200)
committerOrestis Floros <orestisf1993@gmail.com>
Fri, 22 Mar 2019 01:10:00 +0000 (03:10 +0200)
- The result from con_get_output was always not NULL because
con_get_output asserts so
- get_output_by_name should always be able to get an output from the
corresponding container
- workspace_move_to_output doesn't return bool anymore since it can't
fail

include/workspace.h
src/commands.c
src/con.c
src/output.c
src/workspace.c

index db544ce8eea6d154120b5a13118dc033a0c533b4..69974a2e1afaa4a765ba4538404d569aed1c14f9 100644 (file)
@@ -218,7 +218,6 @@ Con *workspace_encapsulate(Con *ws);
 
 /**
  * Move the given workspace to the specified output.
- * This returns true if and only if moving the workspace was successful.
  *
  */
-bool workspace_move_to_output(Con *ws, Output *output);
+void workspace_move_to_output(Con *ws, Output *output);
index 778b4a1a9da95b43c71f3a936515d65f0c852d6c..b7fbce902f324836cab989ab2cfca3bd96e7fc5a 100644 (file)
@@ -1114,22 +1114,13 @@ void cmd_move_workspace_to_output(I3_CMD, const char *name) {
         }
 
         Output *current_output = get_output_for_con(ws);
-        if (current_output == NULL) {
-            yerror("Cannot get current output. This is a bug in i3.");
-            return;
-        }
-
         Output *target_output = get_output_from_string(current_output, name);
         if (!target_output) {
             yerror("Could not get output from string \"%s\"", name);
             return;
         }
 
-        bool success = workspace_move_to_output(ws, target_output);
-        if (!success) {
-            yerror("Failed to move workspace to output.");
-            return;
-        }
+        workspace_move_to_output(ws, target_output);
     }
 
     cmd_output->needs_tree_render = true;
index f904bfe8a8f87b756b95f82a46b18800ec236812..a88909e1695197eccc88d43642374f317b1e54df 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -1400,8 +1400,6 @@ void con_move_to_output(Con *con, Output *output, bool fix_coordinates) {
  */
 bool con_move_to_output_name(Con *con, const char *name, bool fix_coordinates) {
     Output *current_output = get_output_for_con(con);
-    assert(current_output != NULL);
-
     Output *output = get_output_from_string(current_output, name);
     if (output == NULL) {
         ELOG("Could not find output \"%s\"\n", name);
index ebba5c77d40670afefe7b83f92245a5afea3b71f..3d931b1b567aa260d062ba770e3f7b92677dc794 100644 (file)
@@ -54,16 +54,8 @@ char *output_primary_name(Output *output) {
 
 Output *get_output_for_con(Con *con) {
     Con *output_con = con_get_output(con);
-    if (output_con == NULL) {
-        ELOG("Could not get the output container for con = %p.\n", con);
-        return NULL;
-    }
-
     Output *output = get_output_by_name(output_con->name, true);
-    if (output == NULL) {
-        ELOG("Could not get output from name \"%s\".\n", output_con->name);
-        return NULL;
-    }
+    assert(output != NULL);
 
     return output;
 }
index b36885ee9164cb720c7b562791502728f83e42ad..0aeecb456455208f5fa1b74abd15de9060f11217 100644 (file)
@@ -961,17 +961,11 @@ Con *workspace_encapsulate(Con *ws) {
 
 /*
  * Move the given workspace to the specified output.
- * This returns true if and only if moving the workspace was successful.
  */
-bool workspace_move_to_output(Con *ws, Output *output) {
+void workspace_move_to_output(Con *ws, Output *output) {
     DLOG("Moving workspace %p / %s to output %p / \"%s\".\n", ws, ws->name, output, output_primary_name(output));
 
     Output *current_output = get_output_for_con(ws);
-    if (current_output == NULL) {
-        ELOG("Cannot get current output. This is a bug in i3.\n");
-        return false;
-    }
-
     Con *content = output_get_content(output->con);
     DLOG("got output %p with content %p\n", output, content);
 
@@ -1039,7 +1033,7 @@ bool workspace_move_to_output(Con *ws, Output *output) {
     }
 
     if (!previously_visible_ws) {
-        return true;
+        return;
     }
 
     /* NB: We cannot simply work with previously_visible_ws since it might have
@@ -1058,6 +1052,4 @@ bool workspace_move_to_output(Con *ws, Output *output) {
         CALL(previously_visible_ws, on_remove_child);
         break;
     }
-
-    return true;
 }