Patchwork [v2,21/27] qdev: fix off-by-one

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 4, 2012, 8:02 a.m.
Message ID <1328342577-25732-22-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/139546/
State New
Headers show

Comments

Paolo Bonzini - Feb. 4, 2012, 8:02 a.m.
Integer properties did not work.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Anthony Liguori - Feb. 6, 2012, 2:35 p.m.
On 02/04/2012 02:02 AM, Paolo Bonzini wrote:
> Integer properties did not work.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/qdev-properties.c |    6 +++---
>   1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index d69a987..debb37f 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -151,7 +151,7 @@ static void set_int8(Object *obj, Visitor *v, void *opaque,
>           error_propagate(errp, local_err);
>           return;
>       }
> -    if (value>  prop->info->min&&  value<= prop->info->max) {
> +    if (value>= prop->info->min&&  value<= prop->info->max) {
>           *ptr = value;
>       } else {
>           error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
> @@ -259,7 +259,7 @@ static void set_int16(Object *obj, Visitor *v, void *opaque,
>           error_propagate(errp, local_err);
>           return;
>       }
> -    if (value>  prop->info->min&&  value<= prop->info->max) {
> +    if (value>= prop->info->min&&  value<= prop->info->max) {
>           *ptr = value;
>       } else {
>           error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
> @@ -333,7 +333,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
>           error_propagate(errp, local_err);
>           return;
>       }
> -    if (value>  prop->info->min&&  value<= prop->info->max) {
> +    if (value>= prop->info->min&&  value<= prop->info->max) {
>           *ptr = value;
>       } else {
>           error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index d69a987..debb37f 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -151,7 +151,7 @@  static void set_int8(Object *obj, Visitor *v, void *opaque,
         error_propagate(errp, local_err);
         return;
     }
-    if (value > prop->info->min && value <= prop->info->max) {
+    if (value >= prop->info->min && value <= prop->info->max) {
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
@@ -259,7 +259,7 @@  static void set_int16(Object *obj, Visitor *v, void *opaque,
         error_propagate(errp, local_err);
         return;
     }
-    if (value > prop->info->min && value <= prop->info->max) {
+    if (value >= prop->info->min && value <= prop->info->max) {
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
@@ -333,7 +333,7 @@  static void set_int32(Object *obj, Visitor *v, void *opaque,
         error_propagate(errp, local_err);
         return;
     }
-    if (value > prop->info->min && value <= prop->info->max) {
+    if (value >= prop->info->min && value <= prop->info->max) {
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,