From: Sebastien GODARD Date: Sat, 16 Dec 2017 09:41:10 +0000 (+0100) Subject: Use ULLONG_MAX/2 to check if network device counters have overflown X-Git-Tag: v11.7.1~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=436fb8e6cc69fa5a8a8f735b62fce864e34c0544;p=sysstat Use ULLONG_MAX/2 to check if network device counters have overflown Counters's type for stats_net_dev structure is "unsigned long long" (it used to be "unsigned long" before). So use ULLONG_MAX instead of ULONG_MAX to try to guess if counters have overflown. Signed-off-by: Sebastien GODARD --- diff --git a/sa_common.c b/sa_common.c index 254faf2..4e7440d 100644 --- a/sa_common.c +++ b/sa_common.c @@ -648,7 +648,7 @@ int check_net_dev_reg(struct activity *a, int curr, int ref, int pos) * relevant counter has met an overflow condition, and that * the interface was not unregistered, which is all the * more plausible that the previous value for the counter - * was > ULONG_MAX/2. + * was > ULLONG_MAX/2. * NB: the average value displayed will be wrong in this case... * * If such an overflow is detected, just set the flag. There is no @@ -660,22 +660,22 @@ int check_net_dev_reg(struct activity *a, int curr, int ref, int pos) if ((sndc->rx_bytes < sndp->rx_bytes) && (sndc->rx_packets > sndp->rx_packets) && - (sndp->rx_bytes > (~0UL >> 1))) { + (sndp->rx_bytes > (~0ULL >> 1))) { ovfw = TRUE; } if ((sndc->tx_bytes < sndp->tx_bytes) && (sndc->tx_packets > sndp->tx_packets) && - (sndp->tx_bytes > (~0UL >> 1))) { + (sndp->tx_bytes > (~0ULL >> 1))) { ovfw = TRUE; } if ((sndc->rx_packets < sndp->rx_packets) && (sndc->rx_bytes > sndp->rx_bytes) && - (sndp->rx_packets > (~0UL >> 1))) { + (sndp->rx_packets > (~0ULL >> 1))) { ovfw = TRUE; } if ((sndc->tx_packets < sndp->tx_packets) && (sndc->tx_bytes > sndp->tx_bytes) && - (sndp->tx_packets > (~0UL >> 1))) { + (sndp->tx_packets > (~0ULL >> 1))) { ovfw = TRUE; }