tcp: add tcp_min_snd_mss sysctl
[pandora-kernel.git] / lib / bitmap.c
index 2f4412e..389e75e 100644 (file)
@@ -129,7 +129,9 @@ void __bitmap_shift_right(unsigned long *dst,
                lower = src[off + k];
                if (left && off + k == lim - 1)
                        lower &= mask;
-               dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem;
+               dst[k] = lower >> rem;
+               if (rem)
+                       dst[k] |= upper << (BITS_PER_LONG - rem);
                if (left && k == lim - 1)
                        dst[k] &= mask;
        }
@@ -170,7 +172,9 @@ void __bitmap_shift_left(unsigned long *dst,
                upper = src[k];
                if (left && k == lim - 1)
                        upper &= (1UL << left) - 1;
-               dst[k + off] = lower  >> (BITS_PER_LONG - rem) | upper << rem;
+               dst[k + off] = upper << rem;
+               if (rem)
+                       dst[k + off] |= lower >> (BITS_PER_LONG - rem);
                if (left && k + off == lim - 1)
                        dst[k + off] &= (1UL << left) - 1;
        }
@@ -419,7 +423,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
 {
        int c, old_c, totaldigits, ndigits, nchunks, nbits;
        u32 chunk;
-       const char __user *ubuf = buf;
+       const char __user __force *ubuf = (const char __user __force *)buf;
 
        bitmap_zero(maskp, nmaskbits);
 
@@ -504,7 +508,9 @@ int bitmap_parse_user(const char __user *ubuf,
 {
        if (!access_ok(VERIFY_READ, ubuf, ulen))
                return -EFAULT;
-       return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits);
+       return __bitmap_parse((const char __force *)ubuf,
+                               ulen, 1, maskp, nmaskbits);
+
 }
 EXPORT_SYMBOL(bitmap_parse_user);
 
@@ -594,13 +600,13 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
 {
        unsigned a, b;
        int c, old_c, totaldigits;
-       const char __user *ubuf = buf;
-       int exp_digit, in_range;
+       const char __user __force *ubuf = (const char __user __force *)buf;
+       int at_start, in_range;
 
        totaldigits = c = 0;
        bitmap_zero(maskp, nmaskbits);
        do {
-               exp_digit = 1;
+               at_start = 1;
                in_range = 0;
                a = b = 0;
 
@@ -629,11 +635,10 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
                                break;
 
                        if (c == '-') {
-                               if (exp_digit || in_range)
+                               if (at_start || in_range)
                                        return -EINVAL;
                                b = 0;
                                in_range = 1;
-                               exp_digit = 1;
                                continue;
                        }
 
@@ -643,16 +648,18 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
                        b = b * 10 + (c - '0');
                        if (!in_range)
                                a = b;
-                       exp_digit = 0;
+                       at_start = 0;
                        totaldigits++;
                }
                if (!(a <= b))
                        return -EINVAL;
                if (b >= nmaskbits)
                        return -ERANGE;
-               while (a <= b) {
-                       set_bit(a, maskp);
-                       a++;
+               if (!at_start) {
+                       while (a <= b) {
+                               set_bit(a, maskp);
+                               a++;
+                       }
                }
        } while (buflen && c == ',');
        return 0;
@@ -694,7 +701,7 @@ int bitmap_parselist_user(const char __user *ubuf,
 {
        if (!access_ok(VERIFY_READ, ubuf, ulen))
                return -EFAULT;
-       return __bitmap_parselist((const char *)ubuf,
+       return __bitmap_parselist((const char __force *)ubuf,
                                        ulen, 1, maskp, nmaskbits);
 }
 EXPORT_SYMBOL(bitmap_parselist_user);