agm: Fix possible subtraction overflow error
Fix possible subtraction overflow error when computing
the difference in wall clock times between cached and current time
Change-Id: I97eed21bc0fdf303f5301ca4c81dc4e72cd4960f
diff --git a/plugins/tinyalsa/src/agm_pcm_plugin.c b/plugins/tinyalsa/src/agm_pcm_plugin.c
index b8f375f..1dac129 100644
--- a/plugins/tinyalsa/src/agm_pcm_plugin.c
+++ b/plugins/tinyalsa/src/agm_pcm_plugin.c
@@ -365,7 +365,7 @@
new_hw_ptr = hw_base + pos;
// Set delta_wall_clk_us only if cached wall clk is non-zero
- if (priv->pos_buf->wall_clk_msw || priv->pos_buf->wall_clk_lsw) {
+ if (wall_clk_msw != 0 || wall_clk_lsw != 0) {
delta_wall_clk_us = (int64_t)((((uint64_t)wall_clk_msw) << 32 | wall_clk_lsw) -
(((uint64_t)priv->pos_buf->wall_clk_msw) << 32 |
priv->pos_buf->wall_clk_lsw));