qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RfC PATCH 2/2] qdev/prop: convert pci.c to	helper macros.
Date: Fri, 31 Jul 2009 17:42:23 +0200	[thread overview]
Message-ID: <4A7310DF.9070904@redhat.com> (raw)
In-Reply-To: <20090731143251.GA9233@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

   Hi,

>             (long)(&(_prop)->type -&((_struct *)0)->_field)) \

> This seems to be free of gcc extensions and gives more or less sane errors like:
>
> foo.c:26: error: invalid operands to binary - (have ‘long long int *’ and ‘int *’)

The "better error message" bit works.  Nice idea.  Incremental patch 
attached.

cheers,
   Gerd

[-- Attachment #2: 0001-better-type-check.patch --]
[-- Type: text/plain, Size: 945 bytes --]

From cf4d63c456250c7e97705338c3c052fe10a5a4b6 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 31 Jul 2009 17:36:01 +0200
Subject: [PATCH] better type check

---
 hw/qdev.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.h b/hw/qdev.h
index 4fe534e..e2703f4 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -156,10 +156,8 @@ extern PropertyInfo qdev_prop_ptr;
 extern PropertyInfo qdev_prop_macaddr;
 extern PropertyInfo qdev_prop_pci_devfn;
 
-extern int qdev_property_type_check_failed; /* undefined */
 #define typeof_field(type, field) typeof(((type *)0)->field)
-#define type_check(t1,t2) __builtin_choose_expr( \
-        __builtin_types_compatible_p(t1,t2),0,qdev_property_type_check_failed)
+#define type_check(t1,t2) ((t1*)0 - (t2*)0)
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
         .name      = (_name),                                    \
-- 
1.6.2.5


      parent reply	other threads:[~2009-07-31 15:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31 13:04 [Qemu-devel] [RfC PATCH 0/2] qdev/prop: macros for creating typechecked properties Gerd Hoffmann
2009-07-31 13:04 ` [Qemu-devel] [RfC PATCH 1/2] " Gerd Hoffmann
2009-07-31 13:04 ` [Qemu-devel] [RfC PATCH 2/2] qdev/prop: convert pci.c to helper macros Gerd Hoffmann
2009-07-31 14:32   ` Michael S. Tsirkin
2009-07-31 15:01     ` Gerd Hoffmann
2009-07-31 15:42     ` Gerd Hoffmann [this message]

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=4A7310DF.9070904@redhat.com \
    --to=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --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).