From 3724ca0dbb3340de2532527c0b220abc3bdb1ec5 Mon Sep 17 00:00:00 2001 From: Dave Peterson Date: Sat, 14 Aug 2021 17:22:21 -0700 Subject: [PATCH] enable a couple of compiler warnings enable -Wnonnull-compare and -Wnoexcept-type --- SConstruct | 16 +++++++--------- src/base/error_util.cc | 3 +++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/SConstruct b/SConstruct index d6637747..a8393bc5 100644 --- a/SConstruct +++ b/SConstruct @@ -160,10 +160,10 @@ prog_libs = {'pthread', 'dl', 'rt', 'z'} env.Append(CFLAGS=['-Wwrite-strings'], CCFLAGS=['-Wall', '-Wextra', '-Werror', '-Wformat=2', '-Winit-self', '-Wunused-parameter', '-Wshadow', '-Wpointer-arith', - '-Wcast-align', '-Wlogical-op', '-Wno-nonnull-compare'], + '-Wcast-align', '-Wlogical-op'], CPPDEFINES=[('SRC_ROOT', '\'"' + src.abspath + '"\'')], CPPPATH=[src, tclap, gtestincdir], - CXXFLAGS=['-std=c++2a', '-Wold-style-cast', '-Wno-noexcept-type'], + CXXFLAGS=['-std=c++2a', '-Wold-style-cast'], DEP_SUFFIXES=['.cc', '.cpp', '.c', '.cxx', '.c++', '.C'], PROG_LIBS=[lib for lib in prog_libs], TESTSUFFIX='.test', @@ -176,8 +176,7 @@ def set_debug_options(): # libasan on RHEL, Fedora, and CentOS). env.AppendUnique(CCFLAGS=['-g3', '-ggdb', '-fno-omit-frame-pointer', '-fvisibility=hidden']) - env.AppendUnique(CXXFLAGS=['-D_GLIBCXX_DEBUG', - '-D_GLIBCXX_DEBUG_PEDANTIC', + env.AppendUnique(CXXFLAGS=['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC', '-DTRACK_FILE_DESCRIPTORS']) env.AppendUnique(LINKFLAGS=['-rdynamic']) @@ -187,15 +186,14 @@ def set_debug_options(): def set_release_options(): - # Enabling link-time optimizations breaks the build on Ubuntu 15, so for - # now we avoid enabling them. What a chore it is to get stuff to build on - # multiple platforms. :-( + # Enabling link-time optimizations breaks the build on some platforms, so + # for now we avoid enabling them. What a chore it is to get stuff to build + # on multiple platforms. :-( env.AppendUnique(CCFLAGS=['-O2', '-DNDEBUG', '-Wno-unused', '-Wno-unused-parameter', '-fvisibility=hidden']) - # Unfortunately this is needed to prevent spurious build errors on Ubuntu - # 14. :-( + # Unfortunately this is needed to prevent errors on Ubuntu. env.AppendUnique(CPPFLAGS=['-U_FORTIFY_SOURCE']) env.AppendUnique(LINKFLAGS=['-rdynamic']) diff --git a/src/base/error_util.cc b/src/base/error_util.cc index ee86e359..d9f3897b 100644 --- a/src/base/error_util.cc +++ b/src/base/error_util.cc @@ -113,7 +113,10 @@ static void WriteFatalMsgToStderr(const char *msg) noexcept { iov[0].iov_len = std::strlen(msg); iov[1].iov_base = const_cast("\n"); iov[1].iov_len = 1; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" writev(stderr_fd, iov, sizeof(iov) / sizeof(*iov)); +#pragma GCC diagnostic pop } static void EmitStackTrace(const char *msg) {