Fix: counter: cast UINT*_MAX to 64-bit signed type before negative
[lttng-modules.git] / include / counter / counter-api.h
index 827fb6f81bd2df1bc1e9ed6d2e24470eb8a41001..02d709a1e3dd6ca74a9c0fea9bba2e4e4b58597f 100644 (file)
@@ -83,7 +83,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= U8_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -U8_MAX || n > old))
+               else if (v < 0 && (v <= -(s64) U8_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -122,7 +122,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= U16_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -U16_MAX || n > old))
+               else if (v < 0 && (v <= -(s64) U16_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -161,7 +161,7 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                }
                if (v > 0 && (v >= U32_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -U32_MAX || n > old))
+               else if (v < 0 && (v <= -(s64) U32_MAX || n > old))
                        underflow = true;
                break;
        }
This page took 0.025035 seconds and 4 git commands to generate.