lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master eb410dd 02/10: Remove a useless cast


From: Greg Chicares
Subject: [lmi-commits] [lmi] master eb410dd 02/10: Remove a useless cast
Date: Mon, 8 Jun 2020 19:22:00 -0400 (EDT)

branch: master
commit eb410dd3db85a614dfd4c21fa2e38e72fd613c31
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Remove a useless cast
    
    * pchfile_wx.hpp: No longer disable '-Wuseless-cast' for files that
    include wx headers. Using '-isystem' for wx include paths disables this
    warning for wx headers themselves, and removing the warning pragma here
    lets anomalies in lmi code be diagnosed.
    
    * alert_wx.cpp: Resolved a '-Wuseless-cast' warning. The compiler deems
    two types to be the same, but that is not obvious to a human, and the wx
    API could someday change, making such a cast necessary. Rewrote the code
    to deduce the appropriate type.
---
 alert_wx.cpp   | 10 +++++-----
 pchfile_wx.hpp |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/alert_wx.cpp b/alert_wx.cpp
index d60893c..33d8b78 100644
--- a/alert_wx.cpp
+++ b/alert_wx.cpp
@@ -154,11 +154,11 @@ void safe_message_alert(char const* message)
 {
     safely_show_on_stderr(message);
 #if defined LMI_MSW
-    HWND handle = nullptr;
-    if(wxTheApp && wxTheApp->GetTopWindow())
-        {
-        handle = reinterpret_cast<HWND>(wxTheApp->GetTopWindow()->GetHandle());
-        }
+    auto handle =
+        (wxTheApp && wxTheApp->GetTopWindow())
+        ? wxTheApp->GetTopWindow()->GetHandle()
+        : nullptr
+        ;
     ::MessageBoxA(handle, message, "Error", MB_OK | MB_ICONSTOP | 
MB_TASKMODAL);
 #endif // defined LMI_MSW
 }
diff --git a/pchfile_wx.hpp b/pchfile_wx.hpp
index 1001a1c..b9b5b6c 100644
--- a/pchfile_wx.hpp
+++ b/pchfile_wx.hpp
@@ -49,7 +49,6 @@
 #   pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #   pragma GCC diagnostic ignored "-Wnoexcept"
 #   pragma GCC diagnostic ignored "-Wsign-conversion"
-#   pragma GCC diagnostic ignored "-Wuseless-cast"
 #   pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 #endif // defined __GNUC__ && !defined __clang__
 



reply via email to

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