[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 78a4de0 5/7: Enable '-Wnull-dereference'; fix
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 78a4de0 5/7: Enable '-Wnull-dereference'; fix the issues it flags |
Date: |
Fri, 22 Mar 2019 05:53:36 -0400 (EDT) |
branch: master
commit 78a4de074070eae5daf69dfd397297765d8a3793
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Enable '-Wnull-dereference'; fix the issues it flags
Incidentally, shortened an argument name to make the widest line
(aside from the copyright notice) no wider than eighty characters.
---
input_sequence_entry.cpp | 2 +-
main_wx_test.cpp | 6 +++++-
system_command_wx.cpp | 17 +++++++++--------
workhorse.make | 8 +++++---
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 902ef9b..34d1ce9 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -806,7 +806,7 @@ void InputSequenceEditor::remove_row(int row)
int index = row * Col_Max;
wxWindow* win = sizer_->GetItem(index)->GetWindow();
sizer_->Detach(index);
- win->Destroy();
+ win && win->Destroy();
}
redo_layout();
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index a4d5a3d..25ee2a3 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -591,7 +591,11 @@ 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->GetParent();
+ wxWindow* const maybe_book =
+ (maybe_page && maybe_page->GetParent())
+ ? maybe_page->GetParent()
+ : nullptr
+ ;
// 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
diff --git a/system_command_wx.cpp b/system_command_wx.cpp
index b7d9f85..7a28236 100644
--- a/system_command_wx.cpp
+++ b/system_command_wx.cpp
@@ -77,22 +77,23 @@ void assemble_console_lines
/// for the wxEXEC_NODISABLE rationale. This is potentially dangerous,
/// and could be inhibited (by an extra argument) if ever needed.
-void concrete_system_command(std::string const& command_line)
+void concrete_system_command(std::string const& cmd_line)
{
Timer timer;
wxBusyCursor reverie;
- bool const b =
- wxTheApp
- && dynamic_cast<wxFrame*>(wxTheApp->GetTopWindow())
- && dynamic_cast<wxFrame*>(wxTheApp->GetTopWindow())->GetStatusBar()
+ wxFrame const* f =
+ wxTheApp
+ ? dynamic_cast<wxFrame*>(wxTheApp->GetTopWindow())
+ : nullptr;
;
+ bool const b = f && f->GetStatusBar();
std::ostream& statusbar_if_available = b ? status() : null_stream();
statusbar_if_available << "Running..." << std::flush;
wxArrayString output;
wxArrayString errors;
- long int exit_code = wxExecute(command_line, output, errors,
wxEXEC_NODISABLE);
+ long int exit_code = wxExecute(cmd_line, output, errors, wxEXEC_NODISABLE);
statusbar_if_available << timer.stop().elapsed_msec_str() << std::flush;
if(0L == exit_code)
@@ -103,7 +104,7 @@ void concrete_system_command(std::string const&
command_line)
{
alarum()
<< "Command '"
- << command_line
+ << cmd_line
<< "' not recognized."
<< std::flush
;
@@ -114,7 +115,7 @@ void concrete_system_command(std::string const&
command_line)
<< "Exit code "
<< exit_code
<< " from command '"
- << command_line
+ << cmd_line
<< "'.\n"
;
assemble_console_lines(alarum(), output, "Output:");
diff --git a/workhorse.make b/workhorse.make
index 382d8fd..1d4db80 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -447,6 +447,7 @@ gcc_common_warnings := \
-Wlogical-op \
-Wmissing-include-dirs \
-Wmultichar \
+ -Wnull-dereference \
-Wpacked \
-Wpointer-arith \
-Wredundant-decls \
@@ -471,7 +472,6 @@ gcc_common_warnings := \
postponed_gcc_common_warnings := \
-Wmissing-declarations \
- -Wnull-dereference \
-Wswitch-enum \
gcc_c_warnings := \
@@ -615,10 +615,13 @@ endif
# Too many warnings for wx and various boost libraries:
# -Wold-style-cast \
+# See:
+# https://lists.nongnu.org/archive/html/lmi/2019-03/msg00018.html
+$(xmlwrapp_objects): gcc_common_extra_warnings += -Wno-null-dereference
+
# SOMEDAY !! Address some of these '-Wconversion' issues.
wno_conv_objects := \
- $(xmlwrapp_objects) \
CgiUtils.o \
currency_test.o \
rate_table.o \
@@ -632,7 +635,6 @@ wno_sign_conv_objects := \
$(boost_filesystem_objects) \
$(boost_regex_objects) \
$(wx_dependent_objects) \
- $(xmlwrapp_objects) \
CgiEnvironment.o \
CgiUtils.o \
crc32.o \
- [lmi-commits] [lmi] master updated (eebb410 -> ec7be84), Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master c01e2c3 2/7: Make certain classes 'final' as suggested by '-Wsuggest-final-types', Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master 784d552 4/7: Explain why '-Wsign-promo' is not enabled, Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master 5cb593a 3/7: Enable '-Wnon-virtual-dtor'; fix the issues it flags, Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master a1dadae 6/7: Explain why '-Wmissing-declarations' is not enabled, Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master f3cc535 1/7: Revise lists of postponed compiler options, Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master ec7be84 7/7: Enable '-Wswitch-enum'; fix the issues it flags, Greg Chicares, 2019/03/22
- [lmi-commits] [lmi] master 78a4de0 5/7: Enable '-Wnull-dereference'; fix the issues it flags,
Greg Chicares <=