debugobjects: avoid another unused variable warning.
Subsystems (2)
PATCH 1/1 debugobjects: avoid another unused variable warning.
debug_objects_maxchecked is only updated in __debug_check_no_obj_freed(), and only read in debug_objects_maxchecked, unfortunately both of these are optional and depend on different Kconfig symbols. When both CONFIG_DEBUG_OBJECTS_FREE and CONFIG_DEBUG_FS are disabled, we get this warning:
lib/debugobjects.c:56:14: error: 'debug_objects_maxchecked' defined but not used [-Werror=unused-variable]
Rather than trying to add more complex #ifdef protections, this marks the variable as __maybe_unused so it can be silently dropped when usused.
--- lib/debugobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/debugobjects.c +1 -1
@@ -53,7 +53,7 @@ static int obj_nr_tofree;static struct kmem_cache *obj_cache;static int debug_objects_maxchain__read_mostly ; -static int debug_objects_maxchecked__read_mostly ; +static int __maybe_unused debug_objects_maxchecked__read_mostly ;static int debug_objects_fixups__read_mostly ;static int debug_objects_warnings__read_mostly ;static int debug_objects_enabled__read_mostly
Signature · 1 line
2.9.0
Quoted 11 lines · Arnd Bergmann
debug_objects_maxcheckedis only updated in__debug_check_no_obj_freed(), and only read indebug_objects_maxchecked, unfortunately both of these are optional and depend on differentKconfigsymbols. When bothCONFIG_DEBUG_OBJECTS_FREEandCONFIG_DEBUG_FSare disabled, we get this warning:
lib/debugobjects.c:56:14: error: 'debug_objects_maxchecked' defined but not used [-Werror=unused-variable]Rather than trying to add more complex #ifdef protections, this marks the variable as
__maybe_unusedso it can be silently dropped when usused.
Thanks for catching this.
Quoted 20 lines
Fixes bd9dcd046509 ("debugobjects: Export max loops counter")Signed-off-by Arnd Bergmann <[email protected]>--- lib/debugobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/debugobjects.c +1
-1@@ -53,7 +53,7 @@ static int obj_nr_tofree;static struct kmem_cache *obj_cache;static int debug_objects_maxchain__read_mostly ; -static int debug_objects_maxchecked__read_mostly ; +static int __maybe_unused debug_objects_maxchecked__read_mostly ;static int debug_objects_fixups__read_mostly ;static int debug_objects_warnings__read_mostly ;static int debug_objects_enabled__read_mostly
tip-bot for Arnd Bergmann
merge bot[tip:core/debugobjects] debugobjects: Avoid another unused variable warning
In reply to Arnd Bergmanndebugobjects: Avoid another unused variable warning
Commit-ID: 163cf842f5837334bc69aaf09ad38e11f4573914 Gitweb: https://git.kernel.org/tip/163cf842f5837334bc69aaf09ad38e11f4573914 Author: Arnd Bergmann <[email protected]> AuthorDate: Tue, 13 Mar 2018 14:18:46 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Wed, 14 Mar 2018 20:20:01 +0100
debugobjects: Avoid another unused variable warning
debug_objects_maxchecked is only updated in __debug_check_no_obj_freed(), and only read in debug_objects_maxchecked, unfortunately both of these are optional and depend on different Kconfig symbols.
When both CONFIG_DEBUG_OBJECTS_FREE and CONFIG_DEBUG_FS are disabled this warning is emitted:
lib/debugobjects.c:56:14: error: 'debug_objects_maxchecked' defined but not used [-Werror=unused-variable]
Rather than trying to add more complex #ifdef protections, mark the variable as __maybe_unused so it can be silently dropped when usused.
--- lib/debugobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/debugobjects.c +1 -1
@@ -53,7 +53,7 @@ static int obj_nr_tofree;static struct kmem_cache *obj_cache;static int debug_objects_maxchain__read_mostly ; -static int debug_objects_maxchecked__read_mostly ; +static int __maybe_unused debug_objects_maxchecked__read_mostly ;static int debug_objects_fixups__read_mostly ;static int debug_objects_warnings__read_mostly ;static int debug_objects_enabled__read_mostly