]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
compiler: -Werror=return-type hardening
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 19:48:45 +0000 (20:48 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 21:36:31 +0000 (22:36 +0100)
Warn whenever a function is defined with a return type that defaults to
int. Also warn about any return statement with no return value in a
function whose return type is not void (falling off the end of the
function body is considered returning without a value).

For C only, warn about a return statement with an expression in a
function whose return type is void, unless the expression type is also
void. As a GNU extension, the latter case is accepted without a warning
unless -Wpedantic is used.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
configure.ac

index 4daff5b82ce933d6e6c6986d7d99a1963928ff1e..ac628feb8b9c1df6770020a2c19e21af22ed753c 100644 (file)
@@ -707,6 +707,7 @@ AX_CHECK_COMPILE_FLAG([-Wold-style-definition], [CFLAGS="$CFLAGS -Wold-style-def
 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"],,[-Werror])
 AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"],,[-Werror])
 AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=noreturn], [CFLAGS="$CFLAGS -Wsuggest-attribute=noreturn"],,[-Werror])
+AX_CHECK_COMPILE_FLAG([-Werror=return-type], [CFLAGS="$CFLAGS -Werror=return-type"],,[-Werror])
 
 AX_CHECK_LINK_FLAG([-z relro], [LDLAGS="$LDLAGS -z relro"],,[])
 AX_CHECK_LINK_FLAG([-z now], [LDLAGS="$LDLAGS -z now"],,[])