summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-11-28 09:43:57 +0100
committerSébastien Helleu <flashcode@flashtux.org>2020-11-28 09:43:57 +0100
commit4ff4a64209f63cf2a048f7941168336da58727ab (patch)
tree2f6b73fc21ec2b2a534d6ce0bca35ce3e3343e6b
parent21aef706cdf0a7fd4ef19a0ac869efc3e3d96d2e (diff)
downloadweechat-4ff4a64209f63cf2a048f7941168336da58727ab.zip
core: add extra compiler options to check overflow of destination buffer and output truncation
-rw-r--r--CMakeLists.txt4
-rw-r--r--configure.ac4
2 files changed, 4 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c79cc998e..623b0d38a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,8 +27,8 @@ project(weechat C)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
set(CMAKE_SKIP_RPATH ON)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -Wall -Wextra")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration -Wformat-overflow=2 -Wformat-truncation=2")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -Wall -Wextra -Wformat-overflow=2 -Wformat-truncation=2")
# version
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-major OUTPUT_VARIABLE VERSION_MAJOR)
diff --git a/configure.ac b/configure.ac
index 6e707c4dc..7ef5ad5a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1282,8 +1282,8 @@ AC_DEFINE_UNQUOTED(WEECHAT_SHAREDIR, "$WEECHAT_SHAREDIR")
weechat_libdir=${libdir}/weechat
AC_SUBST(weechat_libdir)
-COMMON_CFLAGS="-fsigned-char -Wall -Wextra -Werror-implicit-function-declaration"
-COMMON_CXXFLAGS="-fsigned-char -Wall -Wextra"
+COMMON_CFLAGS="-fsigned-char -Wall -Wextra -Werror-implicit-function-declaration -Wformat-overflow=2 -Wformat-truncation=2"
+COMMON_CXXFLAGS="-fsigned-char -Wall -Wextra -Wformat-overflow=2 -Wformat-truncation=2"
AC_MSG_CHECKING([whether we have GNU assembler])
GAS=`as --version < /dev/null 2>/dev/null | grep GNU`