qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 02/29] Introduce QInt


From: Avi Kivity
Subject: [Qemu-devel] Re: [PATCH 02/29] Introduce QInt
Date: Thu, 13 Aug 2009 16:55:50 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2

On 08/13/2009 04:50 PM, Luiz Capitulino wrote:
+
+/**
+ * qobject_to_qint(): Convert a QObject into a QInt
+ */
+static inline QInt *qobject_to_qint(const QObject *obj)
+{
+    return container_of(obj, QInt, base);
+}
+

It's worthwhile to check the type here and return NULL if not an integer. That allows users to

   QInt *qi = qobject_to_qint(...);

   if (qi) {
       do something
   } else {
       error handling
   }

(this is equivalent to C++'s static_cast vs. dynamic_cast)

--
error compiling committee.c: too many arguments to function





reply via email to

[Prev in Thread] Current Thread [Next in Thread]