From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 93ECE3858404; Wed, 31 Aug 2022 17:14:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93ECE3858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661966080; bh=UJ8pXkP3bo8HNhYyK381F16ivzorsbu28QicFB29Vu8=; h=From:To:Subject:Date:From; b=iRbttdF6SWUI9A9crnlVtbXs9cqBTsuTW5FUUTUvdeeZjzcPl1fR8C/6DTrmSLvXL MYvvjOJUkHPMe6Pqnj9hBGEn54eIFDEw5R5rvONKmHAp32C3g1YxB5nAjeNcmU+avz jhCd80+WZdkzc9i0tjTKdFzL9YBbKkdza1rTnuG4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use member initialization in 'struct ui' X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5a09f120568d433872267887ff844b2278b9c09b X-Git-Newrev: d9f95811860d9b99d539deb80bc6f48f0cee10e8 Message-Id: <20220831171440.93ECE3858404@sourceware.org> Date: Wed, 31 Aug 2022 17:14:40 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd9f95811860d= 9b99d539deb80bc6f48f0cee10e8 commit d9f95811860d9b99d539deb80bc6f48f0cee10e8 Author: Tom Tromey Date: Thu Aug 11 11:13:00 2022 -0600 Use member initialization in 'struct ui' =20 This changes 'struct ui' to use member initialization. This is simpler to understand. Diff: --- 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 d8e0ee5495a..54c7c922142 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -295,26 +295,17 @@ unbuffer_stream (FILE *stream) /* See top.h. */ =20 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); =20 diff --git a/gdb/top.h b/gdb/top.h index 3bd1108f06a..29778f69262 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -61,7 +61,7 @@ struct ui DISABLE_COPY_AND_ASSIGN (ui); =20 /* Pointer to next in singly-linked list. */ - struct ui *next; + struct ui *next =3D nullptr; =20 /* 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) =3D nullptr; =20 /* 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 &&) =3D nullptr; =20 /* 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 =3D 0; =20 /* Each UI has its own independent set of interpreters. */ - struct ui_interp_info *interp_info; + struct ui_interp_info *interp_info =3D nullptr; =20 /* 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 =3D 0; =20 /* The number of nested readline secondary prompts that are currently active. */ - int secondary_prompt_depth; + int secondary_prompt_depth =3D 0; =20 /* The UI's stdin. Set to stdin for the main UI. */ FILE *stdin_stream; @@ -128,7 +128,7 @@ struct ui bool m_input_interactive_p; =20 /* See enum prompt_state's description. */ - enum prompt_state prompt_state; + enum prompt_state prompt_state =3D PROMPT_NEEDED; =20 /* The fields below that start with "m_" are "private". They're meant to be accessed through wrapper macros that make them look @@ -146,7 +146,7 @@ struct ui struct ui_file *m_gdb_stdlog; =20 /* The current ui_out. */ - struct ui_out *m_current_uiout; + struct ui_out *m_current_uiout =3D nullptr; =20 /* Register the UI's input file descriptor in the event loop. */ void register_file_handler ();