diff mbox series

[for-2.11] util/stats64: Fix min/max comparisons

Message ID 20171114232223.25207-1-mreitz@redhat.com
State New
Headers show
Series [for-2.11] util/stats64: Fix min/max comparisons | expand

Commit Message

Max Reitz Nov. 14, 2017, 11:22 p.m. UTC
stat64_min_slow() and stat64_max_slow() compare the wrong way.  This
makes iotest 136 fail with clang and -m32.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 util/stats64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini Nov. 14, 2017, 11:56 p.m. UTC | #1
----- Max Reitz <mreitz@redhat.com> ha scritto:
> stat64_min_slow() and stat64_max_slow() compare the wrong way.  This
> makes iotest 136 fail with clang and -m32.

Queued, thanks.

Cc: qemu-stable@nongnu.org

Paolo

> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  util/stats64.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util/stats64.c b/util/stats64.c
> index 9968fcceac..389c365a9e 100644
> --- a/util/stats64.c
> +++ b/util/stats64.c
> @@ -91,7 +91,7 @@ bool stat64_min_slow(Stat64 *s, uint64_t value)
>      low = atomic_read(&s->low);
>  
>      orig = ((uint64_t)high << 32) | low;
> -    if (orig < value) {
> +    if (value < orig) {
>          /* We have to set low before high, just like stat64_min reads
>           * high before low.  The value may become higher temporarily, but
>           * stat64_get does not notice (it takes the lock) and the only ill
> @@ -120,7 +120,7 @@ bool stat64_max_slow(Stat64 *s, uint64_t value)
>      low = atomic_read(&s->low);
>  
>      orig = ((uint64_t)high << 32) | low;
> -    if (orig > value) {
> +    if (value > orig) {
>          /* We have to set low before high, just like stat64_max reads
>           * high before low.  The value may become lower temporarily, but
>           * stat64_get does not notice (it takes the lock) and the only ill
> -- 
> 2.13.6
>
diff mbox series

Patch

diff --git a/util/stats64.c b/util/stats64.c
index 9968fcceac..389c365a9e 100644
--- a/util/stats64.c
+++ b/util/stats64.c
@@ -91,7 +91,7 @@  bool stat64_min_slow(Stat64 *s, uint64_t value)
     low = atomic_read(&s->low);
 
     orig = ((uint64_t)high << 32) | low;
-    if (orig < value) {
+    if (value < orig) {
         /* We have to set low before high, just like stat64_min reads
          * high before low.  The value may become higher temporarily, but
          * stat64_get does not notice (it takes the lock) and the only ill
@@ -120,7 +120,7 @@  bool stat64_max_slow(Stat64 *s, uint64_t value)
     low = atomic_read(&s->low);
 
     orig = ((uint64_t)high << 32) | low;
-    if (orig > value) {
+    if (value > orig) {
         /* We have to set low before high, just like stat64_max reads
          * high before low.  The value may become lower temporarily, but
          * stat64_get does not notice (it takes the lock) and the only ill