Skip to contentSkip to conversation

lockdep: forward declare struct trask_struct

PATCH In review Heiko Carstens 2 participants 2 messages Feb 7, 2007 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: forward declare struct trask_struct

From: Heiko Carstens <[email protected]>

3117df0453828bd045c16244e6f50e5714667a8a causes this:

In file included from arch/s390/kernel/early.c:13:
include/linux/lockdep.h:300: warning:
"struct task_struct" declared inside parameter list
include/linux/lockdep.h:300:
warning: its scope is only this definition or declaration, which is probably not what you want

Cc Ingo Molnar <[email protected]>
Cc Martin Schwidefsky <[email protected]>
---
 include/linux/lockdep.h |    2 ++
 1 files changed, 2 insertions(+)
include/linux/lockdep.h +2 -0
Index: linux-2.6/include/linux/lockdep.h
===================================================================
@@ -286,6 +286,8 @@ static inline void early_init_irq_lock_c
 }
 #endif
 
+struct task_struct;
+
 #ifdef CONFIG_TRACE_IRQFLAGS
 extern void early_boot_irqs_off(void);
 extern void early_boot_irqs_on(void);
#1 lore raw
Quoted 23 lines · On Wed, 7 Feb 2007 12:23:01 +0100 Heiko Carstens <[email protected]>…

From: Heiko Carstens <[email protected]>

3117df0453828bd045c16244e6f50e5714667a8a causes this:

In file included from arch/s390/kernel/early.c:13:
include/linux/lockdep.h:300: warning:
"struct task_struct" declared inside parameter list
include/linux/lockdep.h:300:
warning: its scope is only this definition or declaration, which is probably not what you want

Cc Ingo Molnar <[email protected]>
Cc Martin Schwidefsky <[email protected]>
---
 include/linux/lockdep.h |    2 ++
 1 files changed, 2 insertions(+)

Index: linux-2.6/include/linux/lockdep.h
===================================================================

include/linux/lockdep.h static inline void early_init_irq_lock_c · line 289

Quoted 4 lines
include/linux/lockdep.h +1 -0
@@ -286,6 +286,8 @@ static inline void early_init_irq_lock_c
 }
 #endif
 
+struct task_struct;

Minor nit: please put such forward declarations right at the top of the header file.

Otherwise someone might come along later and require task_struct at line
100. They'll then add another forward-declaration at line 95 and so on. This has happened in the past.

I updated the patch to do this.

include/linux/lockdep.h renamed from include/linux/lockdep.h~lockdep-forward-declare-struct-trask_struct +2 -0
diff -puN include/linux/lockdep.h~lockdep-forward-declare-struct-trask_struct include/linux/lockdep.h
@@ -8,6 +8,8 @@
 #ifndef __LINUX_LOCKDEP_H
 #define __LINUX_LOCKDEP_H
 
+struct task_struct;
+
 #ifdef CONFIG_LOCKDEP
 
 #include <linux/linkage.h>

_

Note that it's outside CONFIG_LOCKDEP, to avoid possible hey-my-build-broke-when-i-turned-off-lockdep problems.