[lxc-devel] [PATCH] lxc: let it compile ok for gcc7

Dengke Du dengke.du at windriver.com
Thu Jun 22 08:27:42 UTC 2017


After gcc upgrade to 7.1, gcc7 contains a number of enhancements that help
detect buffer overflow and other forms of invalid memory accesses.

When compiling lxc with gcc7, the system outputs errors:

   ../../../lxc-2.0.4/src/lxc/bdev/lxcloop.c:297:30: error: '%s' directive
   output may be truncated writing up to 255 bytes into a region of size 95
   [-Werror=format-truncation=]

This is because in configure.ac, the flag "-Werror" let the compiler treat
the warnings as errors, in order to compile successfully, we should add the
following to the configure.ac:

   -Wno-error=format-truncation

Signed-off-by: Dengke Du <dengke.du at windriver.com>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index b9646d1..c03dc2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -626,7 +626,7 @@ AC_PROG_SED
 LXC_CHECK_TLS
 
 if test "x$GCC" = "xyes"; then
-	CFLAGS="$CFLAGS -Wall -Werror"
+	CFLAGS="$CFLAGS -Wall -Werror -Wno-error=format-truncation"
 fi
 
 # Files requiring some variable expansion
-- 
2.11.0



More information about the lxc-devel mailing list