diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-01-30 17:36:57 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-01-30 16:36:57 +0000 |
commit | d13a8ea18f852e97201269e55255a14fe4fe5d0f (patch) | |
tree | ac308dd7d56af306d49bf7c996ecb6ae424d37b5 /libpam/include | |
parent | e2ada10676aa6ce116964a41f083fa4776e9453a (diff) | |
download | pam-d13a8ea18f852e97201269e55255a14fe4fe5d0f.tar.gz pam-d13a8ea18f852e97201269e55255a14fe4fe5d0f.tar.bz2 pam-d13a8ea18f852e97201269e55255a14fe4fe5d0f.zip |
Enable format compiler warnings
* libpam/include/pam_cc_compat.h (DIAG_PUSH_IGNORE_FORMAT_NONLITERAL,
DIAG_POP_IGNORE_FORMAT_NONLITERAL): New macros.
* libpam/pam_handlers.c (_pam_open_config_file): Use them to exempt
usage of format string literals from a constant array.
* m4/warn_lang_flags.m4 (gl_WARN_ADD): Add -Wformat=2.
Diffstat (limited to 'libpam/include')
-rw-r--r-- | libpam/include/pam_cc_compat.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libpam/include/pam_cc_compat.h b/libpam/include/pam_cc_compat.h index 69190368..0a6e32d5 100644 --- a/libpam/include/pam_cc_compat.h +++ b/libpam/include/pam_cc_compat.h @@ -32,6 +32,11 @@ _Pragma("GCC diagnostic ignored \"-Wcast-align\"") # define DIAG_POP_IGNORE_CAST_ALIGN \ _Pragma("GCC diagnostic pop") +# define DIAG_PUSH_IGNORE_FORMAT_NONLITERAL \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") +# define DIAG_POP_IGNORE_FORMAT_NONLITERAL \ + _Pragma("GCC diagnostic pop") #elif PAM_CLANG_PREREQ(2, 6) # define DIAG_PUSH_IGNORE_CAST_QUAL \ _Pragma("clang diagnostic push"); \ @@ -43,11 +48,18 @@ _Pragma("clang diagnostic ignored \"-Wcast-align\"") # define DIAG_POP_IGNORE_CAST_ALIGN \ _Pragma("clang diagnostic pop") +# define DIAG_PUSH_IGNORE_FORMAT_NONLITERAL \ + _Pragma("clang diagnostic push"); \ + _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") +# define DIAG_POP_IGNORE_FORMAT_NONLITERAL \ + _Pragma("clang diagnostic pop") #else -# define DIAG_PUSH_IGNORE_CAST_QUAL /* empty */ -# define DIAG_POP_IGNORE_CAST_QUAL /* empty */ -# define DIAG_PUSH_IGNORE_CAST_ALIGN /* empty */ -# define DIAG_POP_IGNORE_CAST_ALIGN /* empty */ +# define DIAG_PUSH_IGNORE_CAST_QUAL /* empty */ +# define DIAG_POP_IGNORE_CAST_QUAL /* empty */ +# define DIAG_PUSH_IGNORE_CAST_ALIGN /* empty */ +# define DIAG_POP_IGNORE_CAST_ALIGN /* empty */ +# define DIAG_PUSH_IGNORE_FORMAT_NONLITERAL /* empty */ +# define DIAG_POP_IGNORE_FORMAT_NONLITERAL /* empty */ #endif /* |