From 7bd9f711b6da87ae6376c220590104abc60eb7e8 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 19 Mar 2008 11:16:17 +0000 Subject: [PATCH] renamed format option, added nonnull option [r18985] --- format_check.c | 2 +- warning.c | 12 +++++++++--- warning.h | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/format_check.c b/format_check.c index 99edcce..9c8710b 100644 --- a/format_check.c +++ b/format_check.c @@ -540,7 +540,7 @@ next_arg: void check_format(const call_expression_t *const call) { - if (!warning.check_format) + if (!warning.format) return; const expression_t *const func_expr = call->function; diff --git a/warning.c b/warning.c index ebf5f6a..c93ed20 100644 --- a/warning.c +++ b/warning.c @@ -24,7 +24,8 @@ warning_t warning = { .attribute = true, .char_subscripts = true, - .check_format = true, + .format = true, + .nonnull = true, .empty_statement = false, .fatal_errors = false, .float_equal = false, @@ -68,7 +69,8 @@ void set_warning_opt(const char *const opt) /* Note: this switched on a lot of more warnings than gcc's -Wall */ SET(attribute) SET(char_subscripts) - SET(check_format) + SET(format) + SET(nonnull) SET(empty_statement) SET(implicit_function_declaration) SET(implicit_int) @@ -100,7 +102,11 @@ void set_warning_opt(const char *const opt) } OPT("fatal-errors", fatal_errors) OPT("float-equal", float_equal) - OPT("format", check_format) + OPTX("format") { + SET(format) + SET(nonnull) + } + OPT("nonnull", nonnull) OPTX("implicit") { SET(implicit_function_declaration) SET(implicit_int) diff --git a/warning.h b/warning.h index 743e420..3b3f22f 100644 --- a/warning.h +++ b/warning.h @@ -31,7 +31,8 @@ typedef struct warning_t { #endif bool attribute:1; /**< Warn if an unexpected `__attribute__' is used or function attributes applied to variables, etc. */ bool char_subscripts:1; /**< Warn if an array subscript has the type 'char' */ - bool check_format:1; /**< Check printf-style format strings */ + bool format:1; /**< Check printf-style format strings */ + bool nonnull:1; /**< Warn about passing a null pointer for arguments marked nonnull */ #if 0 // TODO bool cast_align:1; /**< Warn whenever a pointer is cast such that the required alignment of the target is increased */ bool cast_qual:1; /**< Warn whenever a pointer is cast so as to remove a type qualifier from the target type */ -- 2.20.1