Commit report for master branch
Phil Mayers
p.mayers at imperial.ac.uk
Wed Oct 17 10:26:35 CEST 2012
On 10/17/2012 09:04 AM, Brian Candler wrote:
> Aside: this uses "%u", sizeof(...) for the first argument. Is it guaranteed
> that sizeof() is int on all platforms?
Very much not. sizeof returns size_t which is always unsigned (so never
"int"), but otherwise implementation (compiler) dependent. In principle
"%zu" is the correct format spec. However, I'm not sure how widely
supported that is on older compilers - even on current ones.
> I guess if there's any doubt,
>
> "%lu", (long)sizeof(...)
>
> should be pretty safe.
Yuck. Cast of unsigned to signed :oP
TBH it's a fairly theoretical argument; sizeof is used on objects whose
size tends to be in the range 1-100k and specified at compile time. The
odds of sizeof ever returning >2**31 are very, very remote, at least
with current system architectures.
More information about the Freeradius-Devel
mailing list