TSCH: fix signedness in adaptive timesync

This commit is contained in:
Atis Elsts 2016-06-06 23:11:34 +03:00
parent 03d511c2be
commit b57009e564

View File

@ -86,8 +86,8 @@ timesync_entry_add(int32_t val, uint32_t time_delta)
static void
timesync_learn_drift_ticks(uint32_t time_delta_asn, int32_t drift_ticks)
{
/* should fit in 32-bit unsigned integer */
uint32_t time_delta_ticks = time_delta_asn * tsch_timing[tsch_ts_timeslot_length];
/* should fit in a 32-bit integer */
int32_t time_delta_ticks = time_delta_asn * tsch_timing[tsch_ts_timeslot_length];
int32_t real_drift_ticks = drift_ticks + compensated_ticks;
int32_t last_drift_ppm = (int32_t)((int64_t)real_drift_ticks * TSCH_DRIFT_UNIT / time_delta_ticks);