mirror of https://github.com/xemu-project/xemu.git
Fix vmstate_info_int32_le comparison/assign
Fix comparison of vmstate_info_int32_le so that it succeeds if loaded value is (l)ess than or (e)qual When the comparison succeeds, assign the value loaded This is a change in behaviour but I think the original intent, since the idea is to check if the version/size of the thing you're loading is less than some limit, but you might well want to do something based on the actual version/size in the file Fix up comment and name text Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
aded6539d9
commit
24a370ef23
15
vmstate.c
15
vmstate.c
|
@ -321,23 +321,24 @@ const VMStateInfo vmstate_info_int32_equal = {
|
||||||
.put = put_int32,
|
.put = put_int32,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 32 bit int. See that the received value is the less or the same
|
/* 32 bit int. Check that the received value is less than or equal to
|
||||||
than the one in the field */
|
the one in the field */
|
||||||
|
|
||||||
static int get_int32_le(QEMUFile *f, void *pv, size_t size)
|
static int get_int32_le(QEMUFile *f, void *pv, size_t size)
|
||||||
{
|
{
|
||||||
int32_t *old = pv;
|
int32_t *cur = pv;
|
||||||
int32_t new;
|
int32_t loaded;
|
||||||
qemu_get_sbe32s(f, &new);
|
qemu_get_sbe32s(f, &loaded);
|
||||||
|
|
||||||
if (*old <= new) {
|
if (loaded <= *cur) {
|
||||||
|
*cur = loaded;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VMStateInfo vmstate_info_int32_le = {
|
const VMStateInfo vmstate_info_int32_le = {
|
||||||
.name = "int32 equal",
|
.name = "int32 le",
|
||||||
.get = get_int32_le,
|
.get = get_int32_le,
|
||||||
.put = put_int32,
|
.put = put_int32,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue