From: Cyril H. <ch...@su...> - 2012-03-07 12:50:32
|
Hi! > previous discussion on this issue: > > http://marc.info/?l=ltp-list&m=129585256906986&w=2 > > This patch uses uint64_t to make -I option accept larger numbers to > get rid of overflow. > > Signed-off-by: Caspar Zhang <ca...@ca...> > --- > lib/parse_opts.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/parse_opts.c b/lib/parse_opts.c > index fd49cfa..2159d22 100644 > --- a/lib/parse_opts.c > +++ b/lib/parse_opts.c > @@ -708,7 +708,7 @@ static int get_current_time() > int usc_test_looping(int counter) > { > static int first_time = 1; > - static int stop_time = 0; /* stop time in rtc or usecs */ > + static uint64_t stop_time; /* stop time in rtc or usecs */ > static int delay; /* delay in clocks or usecs */ > int hertz = 0; /* clocks per second or usecs per second */ > int ct, end; /* current time, end delay time */ > @@ -733,7 +733,7 @@ int usc_test_looping(int counter) > > if (STD_LOOP_DURATION) { > ct=get_current_time(); > - stop_time = (int)((float)hertz * STD_LOOP_DURATION) + ct; > + stop_time = (uint64_t)((float)hertz * STD_LOOP_DURATION) + ct; > } Looking at the code, there are more problems than that. The get_current_time() return value as well as ct and end would overflow too. I will look at the code and fix it correctly. -- Cyril Hrubis ch...@su... |