Skip to contentSkip to conversation

x86: constify stacktrace_ops

PATCH In review Jan Beulich 2 participants 3 messages Sep 10, 2007 – Sep 17, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: constify stacktrace_ops

.. as they're never written to.

 arch/i386/kernel/traps.c        |    6 +++---
 arch/x86_64/kernel/stacktrace.c |    2 +-
 arch/x86_64/kernel/traps.c      |    4 ++--
 include/asm-x86_64/stacktrace.h |    2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
arch/i386/kernel/traps.c +3 -3
@@ -114,7 +114,7 @@ struct stack_frame {
 
 static inline unsigned long print_context_stack(struct thread_info *tinfo,
 				unsigned long *stack, unsigned long ebp,
-				struct stacktrace_ops *ops, void *data)
+				const struct stacktrace_ops *ops, void *data)
 {
 #ifdef	CONFIG_FRAME_POINTER
 	struct stack_frame *frame = (struct stack_frame *)ebp;
@@ -151,7 +151,7 @@ static inline unsigned long print_contex
 
 void dump_trace(struct task_struct *task, struct pt_regs *regs,
 	        unsigned long *stack,
-		struct stacktrace_ops *ops, void *data)
+		const struct stacktrace_ops *ops, void *data)
 {
 	unsigned long ebp = 0;
 
@@ -223,7 +223,7 @@ static void print_trace_address(void *da
 	touch_nmi_watchdog();
 }
 
-static struct stacktrace_ops print_trace_ops = {
+static const struct stacktrace_ops print_trace_ops = {
 	.warning = print_trace_warning,
 	.warning_symbol = print_trace_warning_symbol,
 	.stack = print_trace_stack,
arch/x86_64/kernel/stacktrace.c +1 -1
@@ -35,7 +35,7 @@ static void save_stack_address(void *dat
 		trace->entries[trace->nr_entries++] = addr;
 }
 
-static struct stacktrace_ops save_stack_ops = {
+static const struct stacktrace_ops save_stack_ops = {
 	.warning = save_stack_warning,
 	.warning_symbol = save_stack_warning_symbol,
 	.stack = save_stack_stack,
arch/x86_64/kernel/traps.c +2 -2
@@ -217,7 +217,7 @@ static inline int valid_stack_ptr(struct
 
 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
 		unsigned long *stack,
-		struct stacktrace_ops *ops, void *data)
+		const struct stacktrace_ops *ops, void *data)
 {
 	const unsigned cpu = get_cpu();
 	unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
@@ -338,7 +338,7 @@ static void print_trace_address(void *da
 	printk_address(addr);
 }
 
-static struct stacktrace_ops print_trace_ops = {
+static const struct stacktrace_ops print_trace_ops = {
 	.warning = print_trace_warning,
 	.warning_symbol = print_trace_warning_symbol,
 	.stack = print_trace_stack,
include/asm-x86_64/stacktrace.h +1 -1
@@ -15,6 +15,6 @@ struct stacktrace_ops {
 };
 
 void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack,
-		struct stacktrace_ops *ops, void *data);
+		const struct stacktrace_ops *ops, void *data);
 
 #endif
#1 lore raw
Quoted 1 line · On Mon, 10 Sep 2007 14:02:17 +0100 "Jan Beulich" <[email protected]> wrote:

.. as they're never written to.

arch/i386/kernel/traps.c: In function 'dump_trace':
arch/i386/kernel/traps.c:197: warning: initialization discards qualifiers from pointer target type

Due to

                struct ops_and_data oad = { .ops = ops, .data = data };

messy to fix.

#2 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Andrew Morton <[email protected]> 16.09.07 12:18 >>>

Quoted 1 line · On Mon, 10 Sep 2007 14:02:17 +0100 "Jan Beulich" <[email protected]> wrote:

.. as they're never written to.

Quoted 8 lines

arch/i386/kernel/traps.c: In function 'dump_trace':
arch/i386/kernel/traps.c:197: warning: initialization discards qualifiers from pointer target type

Due to

               struct ops_and_data oad = { .ops = ops, .data = data };

messy to fix.

Not really - 'struct ops_and_data' can simply have its 'ops' member also be declared 'struct stacktrace_ops *'. I actually have the patch this way here, but since I generally submit patches against Linus' tree, I had to rip out these hunks, since the structure gets added with the unwinder patch.

Jan