]> git.sur5r.net Git - i3/i3/blobdiff - src/main.c
fix a few warnings/places where the clang static analyzer complains
[i3/i3] / src / main.c
index 44c3f3cb6ce05ebfb021c0daef1a70b8e99685e2..aaa5817157f12d8f48f24da9a752ff317ee1ea6c 100644 (file)
@@ -270,7 +270,6 @@ int main(int argc, char *argv[]) {
         {0, 0, 0, 0}
     };
     int option_index = 0, opt;
-    xcb_void_cookie_t colormap_cookie;
 
     setlocale(LC_ALL, "");
 
@@ -319,8 +318,8 @@ int main(int argc, char *argv[]) {
                 set_verbosity(true);
                 break;
             case 'd':
-                LOG("Enabling debug loglevel %s\n", optarg);
-                add_loglevel(optarg);
+                LOG("Enabling debug logging\n");
+                set_debug_logging(true);
                 break;
             case 'l':
                 /* DEPRECATED, ignored for the next 3 versions (3.e, 3.f, 3.g) */
@@ -368,12 +367,12 @@ int main(int argc, char *argv[]) {
                 }
                 /* fall-through */
             default:
-                fprintf(stderr, "Usage: %s [-c configfile] [-d loglevel] [-a] [-v] [-V] [-C]\n", argv[0]);
+                fprintf(stderr, "Usage: %s [-c configfile] [-d all] [-a] [-v] [-V] [-C]\n", argv[0]);
                 fprintf(stderr, "\n");
                 fprintf(stderr, "\t-a          disable autostart ('exec' lines in config)\n");
                 fprintf(stderr, "\t-c <file>   use the provided configfile instead\n");
                 fprintf(stderr, "\t-C          validate configuration file and exit\n");
-                fprintf(stderr, "\t-d <level>  enable debug output with the specified loglevel\n");
+                fprintf(stderr, "\t-d all      enable debug output\n");
                 fprintf(stderr, "\t-L <file>   path to the serialized layout during restarts\n");
                 fprintf(stderr, "\t-v          display version and exit\n");
                 fprintf(stderr, "\t-V          enable verbose mode\n");
@@ -406,7 +405,7 @@ int main(int argc, char *argv[]) {
     /* If the user passes more arguments, we act like i3-msg would: Just send
      * the arguments as an IPC message to i3. This allows for nice semantic
      * commands such as 'i3 border none'. */
-    if (optind < argc) {
+    if (!only_check_config && optind < argc) {
         /* We enable verbose mode so that the user knows what’s going on.
          * This should make it easier to find mistakes when the user passes
          * arguments by mistake. */
@@ -425,7 +424,7 @@ int main(int argc, char *argv[]) {
             }
             optind++;
         }
-        LOG("Command is: %s (%d bytes)\n", payload, strlen(payload));
+        DLOG("Command is: %s (%zd bytes)\n", payload, strlen(payload));
         char *socket_path = root_atom_contents("I3_SOCKET_PATH");
         if (!socket_path) {
             ELOG("Could not get i3 IPC socket path\n");
@@ -541,20 +540,6 @@ int main(int argc, char *argv[]) {
     cookie = xcb_change_window_attributes_checked(conn, root, mask, values);
     check_error(conn, cookie, "Another window manager seems to be running");
 
-    /* By now we already checked for replies once, so let’s see if colormap
-     * creation worked (if requested). */
-    if (colormap != root_screen->default_colormap) {
-        xcb_generic_error_t *error = xcb_request_check(conn, colormap_cookie);
-        if (error != NULL) {
-            ELOG("Could not create ColorMap for 32 bit visual, falling back to X11 default.\n");
-            root_depth = root_screen->root_depth;
-            visual_id = root_screen->root_visual;
-            colormap = root_screen->default_colormap;
-            DLOG("root_depth = %d, visual_id = 0x%08x.\n", root_depth, visual_id);
-            free(error);
-        }
-    }
-
     xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(conn, gcookie, NULL);
     if (greply == NULL) {
         ELOG("Could not get geometry of the root window, exiting\n");
@@ -675,7 +660,6 @@ int main(int argc, char *argv[]) {
     Output *output = NULL;
     if (!(pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL))) {
         ELOG("Could not query pointer position, using first screen\n");
-        output = get_first_output();
     } else {
         DLOG("Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y);
         output = get_output_containing(pointerreply->root_x, pointerreply->root_y);