]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - lib/math/int_log.c
lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense
[thirdparty/linux.git] / lib / math / int_log.c
index 322df25a22d6ab0df92ff256de5149ed7120e1ea..ea98fc0b3fe247c6bade9b2965e02761a695e9db 100644 (file)
@@ -91,7 +91,7 @@ unsigned int intlog2(u32 value)
         *      so we would use the entry 0x18
         */
        significand = value << (31 - msb);
-       logentry = (significand >> 23) & 0xff;
+       logentry = (significand >> 23) % ARRAY_SIZE(logtable);
 
        /**
         *      last step we do is interpolation because of the
@@ -109,7 +109,7 @@ unsigned int intlog2(u32 value)
         *      logtable_next is 256
         */
        interpolation = ((significand & 0x7fffff) *
-                       ((logtable[(logentry + 1) & 0xff] -
+                       ((logtable[(logentry + 1) % ARRAY_SIZE(logtable)] -
                          logtable[logentry]) & 0xffff)) >> 15;
 
        /* now we return the result */