qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Ildar Isaev" <ild@inbox.ru>, "Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PULL 01/10] qdev: Change Property::offset field to ptrdiff_t type
Date: Wed, 18 Nov 2015 21:22:32 +0100	[thread overview]
Message-ID: <1447878161-5009-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1447878161-5009-1-git-send-email-afaerber@suse.de>

From: Ildar Isaev <ild@inbox.ru>

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index e6dbde4..c537969 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;
-- 
2.6.2

  reply	other threads:[~2015-11-18 20:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 20:22 [Qemu-devel] [PULL for-2.5 00/10] QOM devices patch queue 2015-11-18 Andreas Färber
2015-11-18 20:22 ` Andreas Färber [this message]
2015-11-18 20:22 ` [Qemu-devel] [PULL 02/10] qom: Introduce ObjectPropertyIterator struct for iteration Andreas Färber
2015-11-18 20:22 ` [Qemu-devel] [PULL 03/10] qmp: Convert QMP code to use object property iterators Andreas Färber
2015-11-18 20:22 ` [Qemu-devel] [PULL 04/10] vl: Convert machine help " Andreas Färber
  -- strict thread matches above, loose matches on Subject: below --
2015-11-18 20:39 [Qemu-devel] [PULL for-2.5 00/10] QOM devices patch queue 2015-11-18 Andreas Färber
2015-11-18 20:39 ` [Qemu-devel] [PULL 01/10] qdev: Change Property::offset field to ptrdiff_t type Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447878161-5009-2-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=ild@inbox.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).