From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mbamg-0003HB-Jp for qemu-devel@nongnu.org; Thu, 13 Aug 2009 09:56:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mbamc-0003FJ-3t for qemu-devel@nongnu.org; Thu, 13 Aug 2009 09:56:02 -0400 Received: from [199.232.76.173] (port=39310 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mbamc-0003FC-0C for qemu-devel@nongnu.org; Thu, 13 Aug 2009 09:55:58 -0400 Received: from mx2.redhat.com ([66.187.237.31]:33167) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mbama-00045T-Qo for qemu-devel@nongnu.org; Thu, 13 Aug 2009 09:55:57 -0400 Message-ID: <4A841B66.4000907@redhat.com> Date: Thu, 13 Aug 2009 16:55:50 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1250171428-29308-1-git-send-email-lcapitulino@redhat.com> <1250171428-29308-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1250171428-29308-3-git-send-email-lcapitulino@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 02/29] Introduce QInt List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org 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