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 v2 01/10] qdev: Change Property::offset field to ptrdiff_t type
Date: Thu, 19 Nov 2015 15:35:59 +0100	[thread overview]
Message-ID: <1447943768-31393-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1447943768-31393-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-19 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 14:35 [Qemu-devel] [PULL for-2.5 v2 00/10] QOM devices patch queue 2015-11-19 Andreas Färber
2015-11-19 14:35 ` Andreas Färber [this message]
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 02/10] qom: Introduce ObjectPropertyIterator struct for iteration Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 03/10] qmp: Convert QMP code to use object property iterators Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 04/10] vl: Convert machine help " Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 05/10] ppc: Convert spapr " Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 06/10] net: Convert net filter " Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 07/10] qom: Add a test case for complex property finalization Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 08/10] qom: Replace object property list with GHashTable Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 09/10] qom: Clean up assertions to display values on failure Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 10/10] MAINTAINERS: Add check-qom-{interface, proplist} to QOM Andreas Färber
2015-11-19 18:34 ` [Qemu-devel] [PULL for-2.5 v2 00/10] QOM devices patch queue 2015-11-19 Peter Maydell
2015-11-20 11:14 ` Peter Maydell

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=1447943768-31393-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).