commit | 76aaef448fcd9458b07b1d78ea4b79165af0cde0 | [log] [tgz] |
---|---|---|
author | Yu Shan <shanyu@google.com> | Thu Jun 29 18:33:04 2023 -0700 |
committer | Yu Shan <shanyu@google.com> | Fri Jun 30 19:07:17 2023 +0000 |
tree | ca77b883ace5f58dbe76bd253abde2bb47478634 | |
parent | 19af89541f6f7eb49dfecb9df90f817036b85cd2 [diff] |
Fix a type conversion bug. Convert int64_t to long on x86 platform loses info. Test: atest FakeVehicleHardwareTest on cf_gwear_x86. Bug: 288376096 Change-Id: I8826e2c0ba6c3e26af858a1d8f1388b75d537082
diff --git a/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/include/LinearFakeValueGenerator.h b/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/include/LinearFakeValueGenerator.h index d2b701d..2378676 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/include/LinearFakeValueGenerator.h +++ b/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/include/LinearFakeValueGenerator.h
@@ -57,7 +57,7 @@ float dispersion; // Defines minimum and maximum value based on initial value. float increment; // Value that we will be added to currentValue with each timer tick. int64_t interval; - long lastEventTimestamp; + int64_t lastEventTimestamp; }; GeneratorCfg mGenCfg;
diff --git a/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/src/LinearFakeValueGenerator.cpp b/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/src/LinearFakeValueGenerator.cpp index 9133144..fe08dcf 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/src/LinearFakeValueGenerator.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/GeneratorHub/src/LinearFakeValueGenerator.cpp
@@ -86,7 +86,7 @@ if (mGenCfg.lastEventTimestamp == 0) { mGenCfg.lastEventTimestamp = elapsedRealtimeNano(); } else { - long nextEventTime = mGenCfg.lastEventTimestamp + mGenCfg.interval; + int64_t nextEventTime = mGenCfg.lastEventTimestamp + mGenCfg.interval; // Prevent overflow. assert(nextEventTime > mGenCfg.lastEventTimestamp); mGenCfg.lastEventTimestamp = nextEventTime;