[Asterisk-Dev] Re: asterisk/include/asterisk utils.h,1.46,1.47

Luigi Rizzo rizzo at icir.org
Sat Oct 29 10:50:52 MST 2005


On Sat, Oct 29, 2005 at 09:03:36AM -0500, Kevin P. Fleming wrote:
> Tony Mountifield wrote:
> 
> > This should be: res = (int)*input + value;
> > 
> > Without the cast, I believe the compiler is at liberty to evaluate the RHS
> > in short precision (which might still overflow) and only extend on assigning
> > the result to res.
> 
> Absolutely correct. Will fix in a jiffy.

while you are at it, it is probably a good idea
to change by-value arguments to [unsigned] int rather than
short (or often even char's). The compiler will generally pass
them as int anyways, ops on non-native types are often
slower (assuming one cares), and using int enables one to use
more strict compiler checks which is _extremely_ useful.

cheers
luigi



More information about the asterisk-dev mailing list