Re: [chrony-dev] [PATCH] Fix precision loss warnings

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


On Sun, Aug 09, 2015 at 06:09:57PM +1200, Bryan Christianson wrote:
> 
> > On 9/08/2015, at 5:57 pm, Håkan Johansson <f96hajo@xxxxxxxxxxx> wrote:
> > 
> > 
> > Curiosity:  recvfrom and sendto returns ssize_t (which is 64 bits on some
> > platforms), so this would invite for code that could make mistakes, by cutting the values.
> > 
> > Should the return value not rather be put in a ssize_t or some other variable that is large enough?  And if really casted down, first be checked that they fit.
> 
> The result was being truncated (on some platforms) prior to this patch (assigning to variable declared as int) so there is no net change. I don't thing chrony will ever return more than 2 billion bytes in a single read, but maybe that would be a better way to do it. Is ssize_t available on all platforms that chrony supports? I didn't know so chose to maintain the status quo in terms of variable sizes.

I think ssize_t should work everywhere we want chrony to compile. But
as you say we don't write to/read from a buffer larger than 2 GB, so
I'm not sure if saving the result to a ssize_t variable, changing the
printf format to %z in the DEBUG_LOG calls and converting to int later
would have any benefit.

-- 
Miroslav Lichvar

-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/