lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 569810d 1/2: Enable '-Wformat-nonliteral'


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 569810d 1/2: Enable '-Wformat-nonliteral'
Date: Thu, 21 Jun 2018 20:47:34 -0400 (EDT)

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

    Enable '-Wformat-nonliteral'
    
    This warning works well with lmi because nonliteral printf formats are
    used only in one spot.
---
 numeric_io_cast.hpp | 7 +++++++
 pchfile_wx.hpp      | 1 +
 workhorse.make      | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/numeric_io_cast.hpp b/numeric_io_cast.hpp
index e7391c1..06e29bc 100644
--- a/numeric_io_cast.hpp
+++ b/numeric_io_cast.hpp
@@ -214,6 +214,10 @@ struct numeric_converter<std::string, From>
         // The borland rtl has a similar problem.
         char buffer[1 + buffer_length];
         buffer[buffer_length] = '\0';
+#if defined __GNUC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#endif // defined __GNUC__
         int actual_length = std::snprintf
             (buffer
             ,buffer_length
@@ -221,6 +225,9 @@ struct numeric_converter<std::string, From>
             ,numeric_conversion_traits<From>::digits(from)
             ,from
             );
+#if defined __GNUC__
+#   pragma GCC diagnostic pop
+#endif // defined __GNUC__
         if(actual_length < 0)
             {
             std::ostringstream err;
diff --git a/pchfile_wx.hpp b/pchfile_wx.hpp
index 30a65b6..3471629 100644
--- a/pchfile_wx.hpp
+++ b/pchfile_wx.hpp
@@ -36,6 +36,7 @@
 // be disabled for the code using wxWidgets as they occur in wxWidgets headers.
 #if defined __GNUC__
 #   pragma GCC diagnostic ignored "-Wcast-qual"
+#   pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #   pragma GCC diagnostic ignored "-Wsign-conversion"
 #endif // defined __GNUC__
 
diff --git a/workhorse.make b/workhorse.make
index 4b74e8b..781a5fd 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -440,7 +440,7 @@ gcc_common_warnings := \
   -Wduplicated-branches \
   -Wduplicated-cond \
   -Wextra \
-  -Wno-format-nonliteral \
+  -Wformat-nonliteral \
   -Wformat-security \
   -Wformat-signedness \
   -Wformat-y2k \



reply via email to

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