1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

fix: handle new size of sequence number correctly during overflow

This commit is contained in:
Steffen Vogel 2015-06-05 12:26:06 +02:00
parent 93aca598f1
commit bacba17c5c

View file

@ -97,9 +97,9 @@ skip: for(;;) {
}
/* Handle wrap-around of sequence number */
int dist = (UINT16_MAX + p->current->sequence - p->previous->sequence) % UINT16_MAX;
if (dist > UINT16_MAX / 2)
dist -= UINT16_MAX;
int dist = (UINT32_MAX + p->current->sequence - p->previous->sequence) % UINT32_MAX;
if (dist > UINT32_MAX / 2)
dist -= UINT32_MAX;
/* Update sequence histogram */
hist_put(&p->hist_seq, dist);