Re: [RFA record/replay] cast to avoid compiler warning

Andreas Schwab
2008-10-05T11:02:45Z

Mark Kettenis <mark.kettenis@xs4all.nl> writes:

>> From: Andreas Schwab <schwab@suse.de>
>> Date: Sun, 05 Oct 2008 09:11:27 +0200
>>
>> Mark Kettenis <mark.kettenis@xs4all.nl> writes:
>>
>> >> Date: Sat, 04 Oct 2008 11:42:47 -0700
>> >> From: Michael Snyder <msnyder@vmware.com>
>> >>
>> >> Sizeof returns size_t, which is not always the same as int.
>> >> This cast will prevent compiler warnings on some architectures
>> >> (eg. x86_64)
>> >
>> > This is wrong! Better cast to unsigned long and print as %lu.
>>
>> The value will always be a small number.
>
> It is still a bad example. People may copy the idiom and uses it on
> cases where the value is not a small number.

If sizeof returns a too big number you should probably rethink your data
types.

Andreas.

--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃŸe 5, 90409 NÃ¼rnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."