]> git.hungrycats.org Git - linux/commitdiff
[PATCH] lib/idr.c 64-bit fixes
authorAndrew Morton <akpm@digeo.com>
Tue, 18 Feb 2003 13:31:43 +0000 (05:31 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 18 Feb 2003 13:31:43 +0000 (05:31 -0800)
Various overflow problems compiling the lib/idr.c code for ppc64

include/linux/idr.h
lib/idr.c

index 40861ba1114c30594ca88c737d629ec6c573ea17..4995cb68a0fa5d5260a1482dcf6408c1fccca22b 100644 (file)
@@ -28,7 +28,7 @@
 /* Leave the possibility of an incomplete final layer */
 #define MAX_LEVEL (BITS_PER_LONG - RESERVED_ID_BITS + IDR_BITS - 1) / IDR_BITS
 #define MAX_ID_SHIFT (BITS_PER_LONG - RESERVED_ID_BITS)
-#define MAX_ID_BIT (1 << MAX_ID_SHIFT)
+#define MAX_ID_BIT (1L << MAX_ID_SHIFT)
 #define MAX_ID_MASK (MAX_ID_BIT - 1)
 
 /* Number of id_layer structs to leave in free list */
@@ -43,7 +43,7 @@ struct idr_layer {
 struct idr {
        struct idr_layer *top;
        int               layers;
-       int               count;
+       long              count;
        struct idr_layer *id_free;
        int               id_free_cnt;
        spinlock_t        lock;
index f48d714db64c40e2f4ae9961123f728ba9b73610..5e2c8f29da46d01cfb46b8f31f1c62e938d2b495 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -150,7 +150,7 @@ EXPORT_SYMBOL(idr_pre_get);
 
 static inline int sub_alloc(struct idr *idp, int shift, void *ptr)
 {
-       int n, v = 0;
+       long n, v = 0;
        struct idr_layer *p;
        struct idr_layer **pa[MAX_LEVEL];
        struct idr_layer ***paa = &pa[0];
@@ -211,7 +211,7 @@ static inline int sub_alloc(struct idr *idp, int shift, void *ptr)
 
 int idr_get_new(struct idr *idp, void *ptr)
 {
-       int v;
+       long v;
        
        if (idp->id_free_cnt < idp->layers + 1) 
                return (-1);
@@ -236,7 +236,7 @@ int idr_get_new(struct idr *idp, void *ptr)
                idp->count++;
                v += (idp->count << MAX_ID_SHIFT);
                if ( unlikely( v == -1 ))
-                    v += (1 << MAX_ID_SHIFT);
+                    v += (1L << MAX_ID_SHIFT);
        }
        return(v);
 }
@@ -259,7 +259,7 @@ static inline void sub_remove(struct idr *idp, int shift, int id)
                p = p->ary[n];
                shift -= IDR_BITS;
        }
-       if ( likely(p)){
+       if (likely(p != NULL)){
                int n = id & IDR_MASK;
                __clear_bit(n, &p->bitmap);
                p->ary[n] = NULL;