* Willy Tarreau <[EMAIL PROTECTED]> wrote:

> Just a hint: while your code here is correct, it is a good practise to 
> check against < 0 instead, so that if for any reason you sometimes 
> forget to cast to signed, the compiler will emit a warning stating 
> that the condition is always false. This would simply become :
> 
> -             if (key < entry->fair_key) {
> +             if ((s64)(key - entry->fair_key) < 0) {

done :-) (Btw., the key is still s64 so the cast is technically 
unnecessary - but now the code would be correct with the key being u64 
too.)

        Ingo

Index: linux/kernel/sched_fair.c
===================================================================
--- linux.orig/kernel/sched_fair.c
+++ linux/kernel/sched_fair.c
@@ -60,7 +60,7 @@ static inline void __enqueue_task_fair(s
                 * We dont care about collisions. Nodes with
                 * the same key stay together.
                 */
-               if (key < entry->fair_key) {
+               if ((s64)(key - entry->fair_key) < 0) {
                        link = &parent->rb_left;
                } else {
                        link = &parent->rb_right;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to