[PATCH] md: fix compiler warning: large integer implicitly truncated to unsigned type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Compiling a 32bit kernel with CONFIG_LBDAF=n gives this compiler warning:
/drivers/md/md.c: In function ‘super_90_load’:
/drivers/md/md.c:1068:3: warning: large integer implicitly truncated to unsigned type [-Woverflow]

Fix it by casting the calculated value to a sector_t type.

Signed-off-by: Helge Deller <deller@xxxxxx>

diff --git a/drivers/md/md.c b/drivers/md/md.c
index e60cebf..b56f1c7 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1065,7 +1065,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 	 * record this size)
 	 */
 	if (rdev->sectors >= (2ULL << 32) && sb->level >= 1)
-		rdev->sectors = (2ULL << 32) - 2;
+		rdev->sectors = (sector_t) ((2ULL << 32) - 2);
 
 	if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1)
 		/* "this cannot possibly happen" ... */
@@ -1356,7 +1356,7 @@ super_90_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
 	 * 4TB == 2^32 KB, or 2*2^32 sectors.
 	 */
 	if (num_sectors >= (2ULL << 32) && rdev->mddev->level >= 1)
-		num_sectors = (2ULL << 32) - 2;
+		num_sectors = (sector_t) ((2ULL << 32) - 2);
 	md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
 		       rdev->sb_page);
 	md_super_wait(rdev->mddev);

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux