Re: [PATCH 5/6] in_initrd: fix gcc compiler error

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

 



On Fri, 16 Aug 2013 20:21:59 +0200 mwilck@xxxxxxxx wrote:

> On some systems, this code caused a "comparison between signed
> and unsigned" error.
> 
> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
> ---
>  util.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util.c b/util.c
> index 8096e29..491a107 100644
> --- a/util.c
> +++ b/util.c
> @@ -1949,6 +1949,6 @@ int in_initrd(void)
>  	/* This is based on similar function in systemd. */
>  	struct statfs s;
>  	return  statfs("/", &s) >= 0 &&
> -		(s.f_type == TMPFS_MAGIC ||
> -		 s.f_type == RAMFS_MAGIC);
> +		((unsigned long)s.f_type == TMPFS_MAGIC ||
> +		 (unsigned long)s.f_type == RAMFS_MAGIC);
>  }

That is rather horrible.  It seems that some architectures like this field to
be signed and other unsigned.
But aren't TMPFS_MAGIC and  RAMFS_MAGIC simple constants and so signed by
default?
What are that defined to on the system that produces the error?

Maybe we need to cast both LHS and RHS to "unsigned long"....

NeilBrown

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux