提交 3b6ca402 编写于 作者: I Ildar Isaev 提交者: Andreas Färber

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: NIldar Isaev <ild@inbox.ru>
Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 74fcbd22
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册