]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qdev: Change Property::offset field to ptrdiff_t type
authorIldar Isaev <ild@inbox.ru>
Wed, 4 Mar 2015 14:09:46 +0000 (17:09 +0300)
committerAndreas Färber <afaerber@suse.de>
Wed, 18 Nov 2015 20:11:55 +0000 (21:11 +0100)
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>
include/hw/qdev-core.h

index e6dbde42c465ff3047f2fff4f2f1129d4aef5209..c537969f4eed5ab789784010f9f8fee5f79b8699 100644 (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;