2016-04-14 01:22:59

by Shi, Yang

[permalink] [raw]
Subject: [PATCH] lockdep: Include print_collision and helper functions in DEBUG_LOCKDEP

pint_collosion and helper functions are just used when DEBUG_LOCKDEP is
selected, so include them in #ifdef CONFIG_DEBUG_LOCKDEP to avoid the below
"defined but not used" warning when DEBUG_LOCKDEP is off:

kernel/locking/lockdep.c:2051:13: warning: 'print_collision' defined but not used [-Wunused-function]
static void print_collision(struct task_struct *curr,

Signed-off-by: Yang Shi <[email protected]>
---
kernel/locking/lockdep.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 2324ba5..ed94109 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1999,6 +1999,7 @@ static inline int get_first_held_lock(struct task_struct *curr,
return ++i;
}

+#ifdef CONFIG_DEBUG_LOCKDEP
/*
* Returns the next chain_key iteration
*/
@@ -2069,6 +2070,7 @@ static void print_collision(struct task_struct *curr,
printk("\nstack backtrace:\n");
dump_stack();
}
+#endif

/*
* Checks whether the chain and the current held locks are consistent
--
2.0.2


2016-04-15 17:06:47

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] lockdep: Include print_collision and helper functions in DEBUG_LOCKDEP

On Wed, Apr 13, 2016 at 5:57 PM, Yang Shi <[email protected]> wrote:
> pint_collosion and helper functions are just used when DEBUG_LOCKDEP is
> selected, so include them in #ifdef CONFIG_DEBUG_LOCKDEP to avoid the below
> "defined but not used" warning when DEBUG_LOCKDEP is off:
>
> kernel/locking/lockdep.c:2051:13: warning: 'print_collision' defined but not used [-Wunused-function]
> static void print_collision(struct task_struct *curr,
>
> Signed-off-by: Yang Shi <[email protected]>

Thanks, I had noticed this warning too.

Reviewed-by: Kees Cook <[email protected]>

-Kees

> ---
> kernel/locking/lockdep.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 2324ba5..ed94109 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -1999,6 +1999,7 @@ static inline int get_first_held_lock(struct task_struct *curr,
> return ++i;
> }
>
> +#ifdef CONFIG_DEBUG_LOCKDEP
> /*
> * Returns the next chain_key iteration
> */
> @@ -2069,6 +2070,7 @@ static void print_collision(struct task_struct *curr,
> printk("\nstack backtrace:\n");
> dump_stack();
> }
> +#endif
>
> /*
> * Checks whether the chain and the current held locks are consistent
> --
> 2.0.2
>



--
Kees Cook
Chrome OS & Brillo Security