[PATCH 3/3] mkfs_vfat: silence errors on BE platforms

Denys Vlasenko vda.linux at googlemail.com
Sat Nov 7 00:27:27 UTC 2009


On Friday 06 November 2009 10:56, Marc Kleine-Budde wrote:
> Silence this warning, which crashes when CONFIG_WERROR is active:
> 
> cc1: warnings being treated as errors
> util-linux/mkfs_vfat.c: In function 'mkfs_vfat_main':
> util-linux/mkfs_vfat.c:468: error: large integer implicitly truncated to unsigned type
> 
> Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
> ---
>  util-linux/mkfs_vfat.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
> index de88a74..c48e517 100644
> --- a/util-linux/mkfs_vfat.c
> +++ b/util-linux/mkfs_vfat.c
> @@ -174,11 +174,11 @@ void BUG_unsupported_field_size(void);
>  #define STORE_LE(field, value) \
>  do { \
>  	if (sizeof(field) == 4) \
> -		field = cpu_to_le32(value); \
> +		field = (typeof(field))cpu_to_le32(value);	\
>  	else if (sizeof(field) == 2) \
> -		field = cpu_to_le16(value); \
> +		field = (typeof(field))cpu_to_le16(value); \
>  	else if (sizeof(field) == 1) \
> -		field = (value); \
> +		field = (typeof(field))(value); \
>  	else \
>  		BUG_unsupported_field_size(); \
>  } while (0)

Too ugly.

The warning gets emitted from this line

STORE_LE(boot_blk->reserved_sect, reserved_sect);

the value here, reserved_sect, is an enum constant 6.

Can't we just cast it to (uint16_t) on that line?

--
vda


More information about the busybox mailing list