lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master d86e3d9: Improve some '-Wnull-dereference' wo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d86e3d9: Improve some '-Wnull-dereference' workarounds
Date: Fri, 22 Mar 2019 08:08:40 -0400 (EDT)

branch: master
commit d86e3d947c54c88be80bca82321b62710b5fc20e
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Improve some '-Wnull-dereference' workarounds
    
    See:
      https://lists.nongnu.org/archive/html/lmi/2019-03/msg00020.html
---
 input_sequence_entry.cpp | 5 +++--
 main_wx_test.cpp         | 7 ++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 34d1ce9..9cde932 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -805,8 +805,9 @@ void InputSequenceEditor::remove_row(int row)
         {
         int index = row * Col_Max;
         wxWindow* win = sizer_->GetItem(index)->GetWindow();
-        sizer_->Detach(index);
-        win && win->Destroy();
+        LMI_ASSERT(win);
+        sizer_->Detach(index); // Superfluous--Destroy() does this anyway.
+        win->Destroy();
         }
 
     redo_layout();
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 25ee2a3..0f130e0 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -591,11 +591,8 @@ wxWindow* wx_test_focus_controller_child(MvcController& 
dialog, char const* name
     // until we reach it.
     for(wxWindow* maybe_page = w;;)
         {
-        wxWindow* const maybe_book =
-            (maybe_page && maybe_page->GetParent())
-            ? maybe_page->GetParent()
-            : nullptr
-            ;
+        LMI_ASSERT(maybe_page);
+        wxWindow* const maybe_book = maybe_page->GetParent();
 
         // As we know that w is a descendant of the dialog, this check ensures
         // that the loop terminates as sooner or later we must reach the dialog



reply via email to

[Prev in Thread] Current Thread [Next in Thread]