From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id 310CF3858C56 for ; Sat, 13 Aug 2022 00:54:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 310CF3858C56 Received: by mail-io1-xd35.google.com with SMTP id r5so2073866iod.10 for ; Fri, 12 Aug 2022 17:54:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ZYTppIQbzGgWTsmnZZqQzvZVNLuNqKd9yWfbLrnxzG0=; b=oCGTQE9rfRRnX1s7nkMSxeA6Kr81LuK7VF9WmT9PfmcjlaiLpjV8SZSxV8/dOuAYiy YalpukikGS72FPFjOyqa6MEHu2Zt7wYDJeEqaiQs3qkGKOuusUv5rxQZamznzFNbv9n8 9LGk4cC5FdhM5/sAlhdvzJyf3bOp5oeolTFQpi0j2zlmo22urcOvhslLy5Cv2BdYjN9L ZbCcgg7VaQ8qEAcCCC/nwRInai+YDLCTXh4bWVK4ckUs5cIx6Lei/TFSh05LySZTiMzE vpEZJldqfyOEQV5uygd5kwf1sI1z+OCw86Z3++6JivetIU+DeN3Gnno9TUBXA5v0wfDq Bpkg== X-Gm-Message-State: ACgBeo3Ri3mDoN37+x/5TGMmPg47S/ZRhyrRPWBgMEzUtlKMtI9JHttk 4ZNoR1iX2EN0MHBa42kcK8l6MjyVgALWQw== X-Google-Smtp-Source: AA6agR4TAfgkABxTiVi9TfvYawi2NJ+TOvOO0CMXVDoi3rRuxT44pXT9GPTGJ0/DRV1wzCfx/sqc1w== X-Received: by 2002:a05:6602:2ccb:b0:684:f485:d0c1 with SMTP id j11-20020a0566022ccb00b00684f485d0c1mr2718546iow.45.1660352089448; Fri, 12 Aug 2022 17:54:49 -0700 (PDT) Received: from murgatroyd.Home (71-211-185-228.hlrn.qwest.net. [71.211.185.228]) by smtp.gmail.com with ESMTPSA id p17-20020a056638217100b00343455007f7sm494366jak.110.2022.08.12.17.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 17:54:49 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/14] Use member initialization in 'struct ui' Date: Fri, 12 Aug 2022 18:54:35 -0600 Message-Id: <20220813005442.4163512-8-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813005442.4163512-1-tromey@adacore.com> References: <20220813005442.4163512-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2022 00:54:51 -0000 This changes 'struct ui' to use member initialization. This is simpler to understand. --- gdb/top.c | 13 ++----------- gdb/top.h | 18 +++++++++--------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/gdb/top.c b/gdb/top.c index 655bcd77598..b63804b14d1 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -295,26 +295,17 @@ unbuffer_stream (FILE *stream) /* See top.h. */ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) - : next (nullptr), - num (++highest_ui_num), - call_readline (nullptr), - input_handler (nullptr), - command_editing (0), - interp_info (nullptr), - async (0), - secondary_prompt_depth (0), + : num (++highest_ui_num), stdin_stream (instream_), instream (instream_), outstream (outstream_), errstream (errstream_), input_fd (fileno (instream)), m_input_interactive_p (ISATTY (instream)), - prompt_state (PROMPT_NEEDED), m_gdb_stdout (new pager_file (new stdio_file (outstream))), m_gdb_stdin (new stdio_file (instream)), m_gdb_stderr (new stderr_file (errstream)), - m_gdb_stdlog (m_gdb_stderr), - m_current_uiout (nullptr) + m_gdb_stdlog (m_gdb_stderr) { buffer_init (&line_buffer); diff --git a/gdb/top.h b/gdb/top.h index cb3abb80d84..6634738c1a0 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -61,7 +61,7 @@ struct ui DISABLE_COPY_AND_ASSIGN (ui); /* Pointer to next in singly-linked list. */ - struct ui *next; + struct ui *next = nullptr; /* Convenient handle (UI number). Unique across all UIs. */ int num; @@ -76,19 +76,19 @@ struct ui point of invocation. In the special case in which the character read is newline, the function invokes the INPUT_HANDLER callback (see below). */ - void (*call_readline) (gdb_client_data); + void (*call_readline) (gdb_client_data) = nullptr; /* The function to invoke when a complete line of input is ready for processing. */ - void (*input_handler) (gdb::unique_xmalloc_ptr &&); + void (*input_handler) (gdb::unique_xmalloc_ptr &&) = nullptr; /* True if this UI is using the readline library for command editing; false if using GDB's own simple readline emulation, with no editing support. */ - int command_editing; + int command_editing = 0; /* Each UI has its own independent set of interpreters. */ - struct ui_interp_info *interp_info; + struct ui_interp_info *interp_info = nullptr; /* True if the UI is in async mode, false if in sync mode. If in sync mode, a synchronous execution command (e.g, "next") does not @@ -98,11 +98,11 @@ struct ui the top event loop. For the main UI, this starts out disabled, until all the explicit command line arguments (e.g., `gdb -ex "start" -ex "next"') are processed. */ - int async; + int async = 0; /* The number of nested readline secondary prompts that are currently active. */ - int secondary_prompt_depth; + int secondary_prompt_depth = 0; /* The UI's stdin. Set to stdin for the main UI. */ FILE *stdin_stream; @@ -127,7 +127,7 @@ struct ui bool m_input_interactive_p; /* See enum prompt_state's description. */ - enum prompt_state prompt_state; + enum prompt_state prompt_state = PROMPT_NEEDED; /* The fields below that start with "m_" are "private". They're meant to be accessed through wrapper macros that make them look @@ -145,7 +145,7 @@ struct ui struct ui_file *m_gdb_stdlog; /* The current ui_out. */ - struct ui_out *m_current_uiout; + struct ui_out *m_current_uiout = nullptr; /* Register the UI's input file descriptor in the event loop. */ void register_file_handler (); -- 2.34.1