Fix: counter: cast UINT*_MAX to 64-bit signed type before negative
[lttng-ust.git] / libcounter / counter-api.h
index 0a7c0adeecc5f3fb46cdea8d191934eb4113e903..d18fa16ec4dab65e51091cb5e498fa2572736ea1 100644 (file)
@@ -104,7 +104,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= UINT8_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT8_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT8_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -143,7 +143,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= UINT16_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT16_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT16_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -182,7 +182,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= UINT32_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT32_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT32_MAX || n > old))
                        underflow = true;
                break;
        }
This page took 0.023635 seconds and 4 git commands to generate.