[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 1/4] Fix issue affecting get_int32_le() in vmstate
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [RFC 1/4] Fix issue affecting get_int32_le() in vmstate.c |
Date: |
Tue, 25 Feb 2014 15:11:16 -0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Feb 25, 2014 at 05:52:47PM +0100, Alvise Rigo wrote:
> The method is not behaving in the way it's supposed to. It should return
> the new value only if it's less than the actual one.
>
> Signed-off-by: Alvise Rigo <address@hidden>
> ---
> vmstate.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/vmstate.c b/vmstate.c
> index 284b080..038b274 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -326,11 +326,11 @@ const VMStateInfo vmstate_info_int32_equal = {
>
> static int get_int32_le(QEMUFile *f, void *pv, size_t size)
> {
> - int32_t *old = pv;
> - int32_t new;
> - qemu_get_sbe32s(f, &new);
> + int32_t old = *(int32_t *)pv;
> + int32_t *new = pv;
> + qemu_get_sbe32s(f, new);
You are now changing the value in *(int32_t*)pv on every call, instead
of simply ensuring the value is less than the current value. This
doesn't seem to be the intended behavior of
vmstate_info_int32_le/VMSTATE_INT32_LE.
>
> - if (*old <= new) {
> + if (*new <= old) {
> return 0;
> }
> return -EINVAL;
> --
> 1.8.3.2
>
--
Eduardo