Skip to contentSkip to conversation

Reinstate const in next_thread()

PATCH In review Keith Owens 2 participants 3 messages Apr 3, 2006 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reinstate const in next_thread()

Before commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3, next_thread() took a const task_t. Reinstate the const qualifier, getting the next thread never changes the current thread.

include/linux/sched.h +1 -1
Index: linux/include/linux/sched.h
===================================================================
@@ -1205,7 +1205,7 @@ extern void wait_task_inactive(task_t * 
 
 #define thread_group_leader(p)	(p->pid == p->tgid)
 
-static inline task_t *next_thread(task_t *p)
+static inline task_t *next_thread(const task_t *p)
 {
 	return list_entry(rcu_dereference(p->thread_group.next),
 				task_t, thread_group);
#1 lore raw
Quoted 5 lines · Keith Owens

Before commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3, next_thread() took a const task_t. Reinstate the const qualifier, getting the next thread never changes the current thread.

Can do, but why? Does code generation improve?

#2 lore raw
Quoted 8 lines · Andrew Morton (on Mon, 3 Apr 2006 01:33:42 -0700) wrote:
Quoted 5 lines · Keith Owens

Before commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3, next_thread() took a const task_t. Reinstate the const qualifier, getting the next thread never changes the current thread.

Can do, but why? Does code generation improve?

I have not checked. The const qualifier on this type of function falls into the "better safe than sorry" category.