Fix off-by-one error. (#100853)

2002-12-11  Tor Lillqvist  <tml@iki.fi>

	* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
This commit is contained in:
Tor Lillqvist
2002-12-11 23:34:44 +00:00
committed by Tor Lillqvist
parent d7b6f09803
commit 2fbe8d8b5f
8 changed files with 30 additions and 2 deletions

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -1,3 +1,7 @@
2002-12-11 Tor Lillqvist <tml@iki.fi>
* glib/gtimer.c (g_timer_elapsed): Fix off-by-one error. (#100853)
2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi> 2002-12-11 Pauli Virtanen <pauli.virtanen@hut.fi>
* configure.in: Added "fi" to ALL_LINGUAS. * configure.in: Added "fi" to ALL_LINGUAS.

View File

@@ -133,7 +133,7 @@ g_timer_elapsed (GTimer *timer,
/* Check for wraparound, which happens every 49.7 days. */ /* Check for wraparound, which happens every 49.7 days. */
if (timer->end < timer->start) if (timer->end < timer->start)
total = (UINT_MAX - (timer->start - timer->end)) / 1000.0; total = (UINT_MAX - (timer->start - timer->end - 1)) / 1000.0;
else else
total = (timer->end - timer->start) / 1000.0; total = (timer->end - timer->start) / 1000.0;
@@ -141,7 +141,7 @@ g_timer_elapsed (GTimer *timer,
{ {
if (timer->end < timer->start) if (timer->end < timer->start)
*microseconds = *microseconds =
((UINT_MAX - (timer->start - timer->end)) % 1000) * 1000; ((UINT_MAX - (timer->start - timer->end - 1)) % 1000) * 1000;
else else
*microseconds = *microseconds =
((timer->end - timer->start) % 1000) * 1000; ((timer->end - timer->start) % 1000) * 1000;