From: Tom de Vries Date: Tue, 4 Feb 2025 21:11:13 +0000 (+0100) Subject: [gdb/tui] Clean up asserts in tui_source_window_base::refresh_window X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2ead10b2f3bdcf616388c879dd346a5a72bb591;p=thirdparty%2Fbinutils-gdb.git [gdb/tui] Clean up asserts in tui_source_window_base::refresh_window 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 Co-Authored-By: Andrew Burgess Approved-By: Andrew Burgess --- diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index a5d0c594545..83d9fc09d11 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -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;