]> granicus.if.org Git - sysstat/commitdiff
Use ULLONG_MAX/2 to check if network device counters have overflown
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Dec 2017 09:41:10 +0000 (10:41 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Dec 2017 09:41:10 +0000 (10:41 +0100)
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 <sysstat@users.noreply.github.com>
sa_common.c

index 254faf2b6606a913be3a8531acbcf42b2d0b3b9b..4e7440da5a43cd95cc673ed08747a9de25080051 100644 (file)
@@ -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;
                                }