linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] debugobjects: avoid another unused variable warning.
@ 2018-03-13 13:18 Arnd Bergmann
  2018-03-13 18:29 ` Yang Shi
  2018-03-14 19:25 ` [tip:core/debugobjects] debugobjects: Avoid " tip-bot for Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-03-13 13:18 UTC (permalink / raw)
  To: Thomas Gleixner, Yang Shi; +Cc: Arnd Bergmann, Waiman Long, linux-kernel

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.

Fixes: bd9dcd046509 ("debugobjects: Export max loops counter")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 lib/debugobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 105ecfc47d8c..994be4805cec 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -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
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] debugobjects: avoid another unused variable warning.
  2018-03-13 13:18 [PATCH] debugobjects: avoid another unused variable warning Arnd Bergmann
@ 2018-03-13 18:29 ` Yang Shi
  2018-03-14 19:25 ` [tip:core/debugobjects] debugobjects: Avoid " tip-bot for Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Yang Shi @ 2018-03-13 18:29 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner; +Cc: Waiman Long, linux-kernel



On 3/13/18 6:18 AM, Arnd Bergmann wrote:
> 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.

Thanks for catching this.

Acked-by: Yang Shi <yang.shi@linux.alibaba.com>

>
> Fixes: bd9dcd046509 ("debugobjects: Export max loops counter")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   lib/debugobjects.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/debugobjects.c b/lib/debugobjects.c
> index 105ecfc47d8c..994be4805cec 100644
> --- a/lib/debugobjects.c
> +++ b/lib/debugobjects.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:core/debugobjects] debugobjects: Avoid another unused variable warning
  2018-03-13 13:18 [PATCH] debugobjects: avoid another unused variable warning Arnd Bergmann
  2018-03-13 18:29 ` Yang Shi
@ 2018-03-14 19:25 ` tip-bot for Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Arnd Bergmann @ 2018-03-14 19:25 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, longman, arnd, linux-kernel, yang.shi, tglx, hpa

Commit-ID:  163cf842f5837334bc69aaf09ad38e11f4573914
Gitweb:     https://git.kernel.org/tip/163cf842f5837334bc69aaf09ad38e11f4573914
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Tue, 13 Mar 2018 14:18:46 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Fixes: bd9dcd046509 ("debugobjects: Export max loops counter")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Yang Shi <yang.shi@linux.alibaba.com>
Cc: Waiman Long <longman@redhat.com>
Link: https://lkml.kernel.org/r/20180313131857.158876-1-arnd@arndb.de

---
 lib/debugobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 105ecfc47d8c..994be4805cec 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-14 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13 13:18 [PATCH] debugobjects: avoid another unused variable warning Arnd Bergmann
2018-03-13 18:29 ` Yang Shi
2018-03-14 19:25 ` [tip:core/debugobjects] debugobjects: Avoid " tip-bot for Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).