From 49e545f5e9872f7698bae46553c0274efe49420e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 22 Feb 2016 15:18:02 -0500 Subject: [PATCH] Cleanup: lift function call outside of condition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/clock.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/formats/ctf/ir/clock.c b/formats/ctf/ir/clock.c index 253b033da..9256bc1f2 100644 --- a/formats/ctf/ir/clock.c +++ b/formats/ctf/ir/clock.c @@ -365,6 +365,7 @@ end: int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time) { int ret = 0; + int64_t value; /* Timestamps are strictly monotonic */ if (!clock) { @@ -384,13 +385,13 @@ int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time) /* Common case where cycles are actually nanoseconds */ if (clock->frequency == 1000000000) { - clock->value = time; - goto end; + value = time; + } else { + value = (uint64_t) (((double) time * + (double) clock->frequency) / 1e9); } - ret = bt_ctf_clock_set_value(clock, - (uint64_t) (((double) time * (double) clock->frequency) / 1e9)); - + ret = bt_ctf_clock_set_value(clock, value); end: return ret; } -- 2.34.1