summary refs log tree commit diff stats
path: root/include/hw/qdev-core.h
diff options
context:
space:
mode:
authorIldar Isaev <ild@inbox.ru>2015-03-04 17:09:46 +0300
committerAndreas Färber <afaerber@suse.de>2015-11-18 21:11:55 +0100
commit3b6ca4022d150ad273d4cd9556c2f4873389f965 (patch)
treee419c8498dc1b70f648d22a8131c3b38c7917175 /include/hw/qdev-core.h
parent74fcbd22d20a2fbc1a47a7b00cce5bf98fd7be5f (diff)
downloadfocaccia-qemu-3b6ca4022d150ad273d4cd9556c2f4873389f965.tar.gz
focaccia-qemu-3b6ca4022d150ad273d4cd9556c2f4873389f965.zip
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>
Diffstat (limited to 'include/hw/qdev-core.h')
-rw-r--r--include/hw/qdev-core.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index e6dbde42c4..c537969f4e 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -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;