]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/tui] Clean up asserts in tui_source_window_base::refresh_window
authorTom de Vries <tdevries@suse.de>
Tue, 4 Feb 2025 21:11:13 +0000 (22:11 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 4 Feb 2025 21:11:13 +0000 (22:11 +0100)
Commit 1c525b0e037 ("[gdb/tui] Fix assert in
tui_source_window_base::refresh_window") added an early return in
tui_source_window_base::refresh_window.

Assert after the early return that "m_pad != nullptr", and clean up the
following asserts that allow for m_pad == nullptr.

Tested on x86_64-linux.

Reported-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/tui/tui-winsource.c

index a5d0c5945456f690c17533c6f9d2a292958f6d82..83d9fc09d11b6041e4d2abd2c220bf372e2857b3 100644 (file)
@@ -316,6 +316,7 @@ tui_source_window_base::refresh_window ()
 
   if (m_content.empty ())
     return;
+  gdb_assert (m_pad != nullptr);
 
   int pad_width = getmaxx (m_pad.get ());
   int left_margin = this->left_margin ();
@@ -339,8 +340,8 @@ tui_source_window_base::refresh_window ()
      should only occur during the initial startup.  In this case the first
      condition in the following asserts will not be true, but the nullptr
      check will.  */
-  gdb_assert (pad_width > 0 || m_pad.get () == nullptr);
-  gdb_assert (pad_x + view_width <= pad_width || m_pad.get () == nullptr);
+  gdb_assert (pad_width > 0);
+  gdb_assert (pad_x + view_width <= pad_width);
 
   int sminrow = y + box_width ();
   int smincol = x + box_width () + left_margin;