From: Jesper Juhl In kernel/sched.c the return value from preempt_count() is cast to an int. That made sense when preempt_count was defined as different types on is not needed and should go away. The patch removes the cast. In kernel/timer.c the return value from preempt_count() is assigned to a variable of type u32 and then that unsigned value is later compared to preempt_count(). Since preempt_count() returns an int, an int is what should be used to store its return value. Storing the result in an unsigned 32bit integer made a tiny bit of sense back when preempt_count was different types on different archs, but no more - let's not play signed vs unsigned comparison games when we don't have to. The patch modifies the code to use an int to hold the value. While I was around that bit of code I also made two changes to a nearby (related) printk() - I modified it to specify the loglevel explicitly and also broke the line into a few pieces to avoid it being longer than 80 chars and clarified the text a bit. Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton --- kernel/sched.c | 2 +- kernel/timer.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff -puN kernel/sched.c~preempt_count-is-int-remove-cast-and-dont-assign-to kernel/sched.c --- 25/kernel/sched.c~preempt_count-is-int-remove-cast-and-dont-assign-to 2005-05-03 16:14:23.000000000 -0700 +++ 25-akpm/kernel/sched.c 2005-05-03 16:14:23.000000000 -0700 @@ -2576,7 +2576,7 @@ void fastcall add_preempt_count(int val) /* * Underflow? */ - BUG_ON(((int)preempt_count() < 0)); + BUG_ON((preempt_count() < 0)); preempt_count() += val; /* * Spinlock count overflowing soon? diff -puN kernel/timer.c~preempt_count-is-int-remove-cast-and-dont-assign-to kernel/timer.c --- 25/kernel/timer.c~preempt_count-is-int-remove-cast-and-dont-assign-to 2005-05-03 16:14:23.000000000 -0700 +++ 25-akpm/kernel/timer.c 2005-05-03 16:14:23.000000000 -0700 @@ -476,10 +476,14 @@ static inline void __run_timers(tvec_bas detach_timer(timer, 1); spin_unlock_irq(&base->t_base.lock); { - u32 preempt_count = preempt_count(); + int preempt_count = preempt_count(); fn(data); if (preempt_count != preempt_count()) { - printk("huh, entered %p with %08x, exited with %08x?\n", fn, preempt_count, preempt_count()); + printk(KERN_WARNING "huh, entered %p " + "with preempt_count %08x, exited" + " with %08x?\n", + fn, preempt_count, + preempt_count()); BUG(); } } _