]> git.hungrycats.org Git - linux/commitdiff
[PATCH] asm-generic/div64.h breakage
authorBernardo Innocenti <bernie@develer.com>
Sat, 12 Jul 2003 02:35:48 +0000 (19:35 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Sat, 12 Jul 2003 02:35:48 +0000 (19:35 -0700)
 - __div64_32(): remove __attribute_pure__ qualifier from the prototype
   since this function obviously clobbers memory through &(n);

 - do_div(): add a check to ensure (n) is type-compatible with uint64_t;

 - as_update_iohist(): Use sector_div() instead of do_div().
   (Whether the result of the addition should always be stored in 64bits
   regardless of CONFIG_LBD is still being discussed, therefore it's
   unadderessed here);

 - Fix all places where do_div() was being called with a bad divisor argument.

drivers/block/as-iosched.c
include/asm-generic/div64.h
lib/vsprintf.c
mm/vmscan.c

index b19289348fb0ef770da5cc8dfa4a4f1ea544db72..df1e95f24c7a9e6ee9fe4e0f5ed8d1704fe43922 100644 (file)
@@ -837,7 +837,7 @@ static void as_update_iohist(struct as_io_context *aic, struct request *rq)
                aic->seek_total += 256*seek_dist;
                if (aic->seek_samples) {
                        aic->seek_mean = aic->seek_total + 128;
-                       do_div(aic->seek_mean, aic->seek_samples);
+                       sector_div(aic->seek_mean, aic->seek_samples);
                }
                aic->seek_samples = (aic->seek_samples>>1)
                                        + (aic->seek_samples>>2);
index b0b1805a74191631b5157c3c36d695d31bc2acce..8f4e3193342e589b8c619e8c2673c3d5544e49a9 100644 (file)
 
 #elif BITS_PER_LONG == 32
 
-extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor) __attribute_pure__;
+extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
 
+/* The unnecessary pointer compare is there
+ * to check for type safety (n must be 64bit)
+ */
 # define do_div(n,base) ({                             \
        uint32_t __base = (base);                       \
        uint32_t __rem;                                 \
+       (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
        if (likely(((n) >> 32) == 0)) {                 \
                __rem = (uint32_t)(n) % __base;         \
                (n) = (uint32_t)(n) / __base;           \
index f790458f4520a56310f920014a736cf11cc8be49..bc699e295bce939f45b31c0b16e4e38bd70185d7 100644 (file)
@@ -127,7 +127,7 @@ static int skip_atoi(const char **s)
 #define SPECIAL        32              /* 0x */
 #define LARGE  64              /* use 'ABCDEF' instead of 'abcdef' */
 
-static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
+static char * number(char * buf, char * end, unsigned long long num, int base, int size, int precision, int type)
 {
        char c,sign,tmp[66];
        const char *digits;
index de6889ae257a45ba492faae9309da9e488bd31b9..58fa07f010d90b2f460a948dc2c844ef241e3e64 100644 (file)
@@ -147,7 +147,7 @@ static int shrink_slab(long scanned, unsigned int gfp_mask)
 
        pages = nr_used_zone_pages();
        list_for_each_entry(shrinker, &shrinker_list, list) {
-               long long delta;
+               unsigned long long delta;
 
                delta = scanned * shrinker->seeks;
                delta *= (*shrinker->shrinker)(0, gfp_mask);