qdev: Change Property::offset field to ptrdiff_t type

Property::offset field is calculated as a diff between two pointers:

  arrayprop->prop.offset = eltptr - (void *)dev;

If offset is declared as int, this subtraction can cause type overflow,
thus leading to failure of the subsequent assertion:

  assert(qdev_get_prop_ptr(dev, &arrayprop->prop) == eltptr);

So ptrdiff_t should be used instead.

Signed-off-by: Ildar Isaev <ild@inbox.ru>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
master
Ildar Isaev 2015-03-04 17:09:46 +03:00 committed by Andreas Färber
parent 74fcbd22d2
commit 3b6ca4022d
1 changed files with 1 additions and 1 deletions

View File

@ -237,7 +237,7 @@ struct BusState {
struct Property {
const char *name;
PropertyInfo *info;
int offset;
ptrdiff_t offset;
uint8_t bitnr;
qtype_code qtype;
int64_t defval;