Re: [PATCH] Fix compilation warning on 64 bits platforms

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

 



Al Viro wrote:
> On Sun, May 20, 2007 at 05:28:37PM -0700, Josh Triplett wrote:
>> Damien Lespiau wrote:
>>> Fix: format '%d' expects type 'int', but argument 2 has type 'long int'
>> [...]
>>> @@ -461,7 +461,7 @@ const char *show_instruction(struct instruction *insn)
>>>  	}
>>>  
>>>  	if (buf >= buffer + sizeof(buffer))
>>> -		die("instruction buffer overflowed %d\n", buf - buffer);
>>> +		die("instruction buffer overflowed %d\n", (int)(buf - buffer));
>> A cast doesn't seem like the right fix.  The difference between two pointers
>> has type ptrdiff_t.  sizeof(ptrdiff_t) == 8 on 64-bit platforms, leading to
>> the legitimate warning you saw.  This cast would truncate the difference to 32
>> bits.  glibc supplies a "t" length modifier for ptrdiff_t, but I don't think
>> sparse can't portably use that.
> 
> Not just glibc; it's in C99.  So yes, I'd say we should use %td here.

Ah, perfect.  Yes, we should use %td.

- Josh Triplett


Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux