From a2333c8938af4829a8eac8c09615e6652cd412f1 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 28 Mar 2009 19:08:23 +0000 Subject: randomtest fixes --- util-linux/mkfs_vfat.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'util-linux') diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 705c75c20..72c2058b5 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c @@ -323,9 +323,20 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv) * fs size <= 16G: 8k clusters * fs size > 16G: 16k clusters */ - sect_per_clust = volume_size_bytes >= ((off_t)16)*1024*1024*1024 ? 32 : - volume_size_bytes >= ((off_t)8)*1024*1024*1024 ? 16 : - volume_size_bytes >= 260*1024*1024 ? 8 : 1; + sect_per_clust = 1; + if (volume_size_bytes >= 260*1024*1024) { + sect_per_clust = 8; + /* fight gcc: */ + /* "error: integer overflow in expression" */ + /* "error: right shift count >= width of type" */ + if (sizeof(off_t) > 4) { + unsigned t = (volume_size_bytes >> 31 >> 1); + if (t >= 8/4) + sect_per_clust = 16; + if (t >= 16/4) + sect_per_clust = 32; + } + } } else { // floppy, loop, or regular file int not_floppy = ioctl(dev, FDGETPRM, ¶m); -- cgit v1.2.3