X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libcounter%2Fcounter-api.h;h=540055aeec616616c14d2eefee410e53c5109792;hb=8406222c45d29b23064d688e33be84894a51baac;hp=0a7c0adeecc5f3fb46cdea8d191934eb4113e903;hpb=ebabbf580131acd1fe246c4d31fc5c044d36a038;p=lttng-ust.git diff --git a/libcounter/counter-api.h b/libcounter/counter-api.h index 0a7c0ade..540055ae 100644 --- a/libcounter/counter-api.h +++ b/libcounter/counter-api.h @@ -101,10 +101,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config, } while (old != res); break; } + default: + return -EINVAL; } 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; } @@ -140,10 +142,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config, } while (old != res); break; } + default: + return -EINVAL; } 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; } @@ -179,10 +183,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config, } while (old != res); break; } + default: + return -EINVAL; } 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; } @@ -219,6 +225,8 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config, } while (old != res); break; } + default: + return -EINVAL; } if (v > 0 && n < old) overflow = true;