> On Mar 25, 2019, at 9:08 PM, Richard Cochran <[email protected]> wrote: > > On Mon, Mar 25, 2019 at 07:46:19PM +0000, Patel, Vedang wrote: >>>> +static int check_offset_threshold(struct servo *s, int64_t offset) >>>> +{ >>>> + uint64_t abs_offset = abs(offset); >>> >>> abs() returns an int... >>> >>>> + if (s->offset_threshold) { >>>> + if (abs_offset < INT64_MAX && abs_offset < s->offset_threshold >>> ^^^^^^^^^^^^^^^^^^^^^^ >>> ... so this test is always true >>> >> Sorry I missed this. Will change it to INT_MAX. > > But are you sure that works? > > What happens when your 'int64_t offset' is degraded into an 'int' in > the call to abs()? > > Better to use llabs(), don't you think? Yeah llabs should work. But, depending on the machine, int64_t will translate to either ‘long int’ or 'long long int’. So, do you think imaxabs will be better to use instead?
Thanks, Vedang > > Thanks, > Richard _______________________________________________ Linuxptp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
