]> 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>
Wed, 10 Apr 2019 16:45:54 +0000 (18:45 +0200)
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 c87ab270b2ba72bc65aca5757a1086f08f1d4380..75d4158cce33124b03638e6e415bad21aa317430 100644 (file)
@@ -699,6 +699,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"],,[])