[git commit] mkfs_ext2, mkfs_vfat: fix warnings in STORE_LE on big-endian platforms

Denys Vlasenko vda.linux at googlemail.com
Thu Feb 15 12:46:34 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=7398892ac0592999397532ba168376edd402438c
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

"warning: large integer implicitly truncated to unsigned type [-Woverflow]"

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 util-linux/mkfs_ext2.c | 6 +++---
 util-linux/mkfs_vfat.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index 8434dd6ad..f524bc239 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -83,11 +83,11 @@ char BUG_wrong_field_size(void);
 #define STORE_LE(field, value) \
 do { \
 	if (sizeof(field) == 4) \
-		field = SWAP_LE32(value); \
+		field = SWAP_LE32((uint32_t)(value)); \
 	else if (sizeof(field) == 2) \
-		field = SWAP_LE16(value); \
+		field = SWAP_LE16((uint16_t)(value)); \
 	else if (sizeof(field) == 1) \
-		field = (value); \
+		field = (uint8_t)(value); \
 	else \
 		BUG_wrong_field_size(); \
 } while (0)
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index 426854b1e..26a919536 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -210,11 +210,11 @@ void BUG_unsupported_field_size(void);
 #define STORE_LE(field, value) \
 do { \
 	if (sizeof(field) == 4) \
-		field = SWAP_LE32(value); \
+		field = SWAP_LE32((uint32_t)(value)); \
 	else if (sizeof(field) == 2) \
-		field = SWAP_LE16(value); \
+		field = SWAP_LE16((uint16_t)(value)); \
 	else if (sizeof(field) == 1) \
-		field = (value); \
+		field = (uint8_t)(value); \
 	else \
 		BUG_unsupported_field_size(); \
 } while (0)


More information about the busybox-cvs mailing list