Fix nfcsnoop_cb on overflow sanitized builds. am: c3ec66ef5b am: 53309f9f87
am: 6b70634310
Change-Id: I6d376d29d8e0546b024482bc148a0fd7707b1184
diff --git a/src/adaptation/debug_nfcsnoop.cc b/src/adaptation/debug_nfcsnoop.cc
index b58554e..9466b9f 100644
--- a/src/adaptation/debug_nfcsnoop.cc
+++ b/src/adaptation/debug_nfcsnoop.cc
@@ -60,8 +60,13 @@
// Insert data
header.length = length;
header.is_received = is_received ? 1 : 0;
- header.delta_time_ms =
- last_timestamp_ms ? timestamp_us - last_timestamp_ms : 0;
+
+ uint64_t delta_time_ms = 0;
+ if (last_timestamp_ms) {
+ __builtin_sub_overflow(timestamp_us, last_timestamp_ms, &delta_time_ms);
+ }
+ header.delta_time_ms = delta_time_ms;
+
last_timestamp_ms = timestamp_us;
ringbuffer_insert(buffer, (uint8_t*)&header, sizeof(nfcsnooz_header_t));