/usr/src/linux/drivers/md/bitmap.c: strange rounding lines 855-875
Hi,
I just found this strange rounding code in /usr/src/linux/drivers/md/bitmap.c: -----snip------- /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ bitmap->filemap_attr = kzalloc( (((num_pages*4/8)+sizeof(unsigned long)) /sizeof(unsigned long)) *sizeof(unsigned long), GFP_KERNEL); ---------snip----- IMHO, this is not rounding, it's just adding one extra "sizeof(unsigned long)": Instead of using the pattern "((a + b) / b) * b" == (a/b + 1) * b == a + b the pattern "((a + b - 1) / b) * b" should be used. Even preferrable: define one macro that does it right, then use it. Example: #define ROUND_UP(n, g) ((((n) + (g) - 1) / (g)) * (g)) #define ROUND_DWN(n, g) (((n) / (g)) * (g)) Regards, Ulrich -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel |
| All times are GMT. The time now is 06:22 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.