From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53814 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwatB-0003Xu-DM for qemu-devel@nongnu.org; Mon, 07 Mar 2011 08:54:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwatA-0002qq-CT for qemu-devel@nongnu.org; Mon, 07 Mar 2011 08:54:21 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:58052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwatA-0002qc-6U for qemu-devel@nongnu.org; Mon, 07 Mar 2011 08:54:20 -0500 Received: by gyd8 with SMTP id 8so2066029gyd.4 for ; Mon, 07 Mar 2011 05:54:19 -0800 (PST) Message-ID: <4D74E38A.90204@codemonkey.ws> Date: Mon, 07 Mar 2011 07:54:18 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 10/22] qapi: add core QMP server support References: <1299460984-15849-1-git-send-email-aliguori@us.ibm.com> <1299460984-15849-11-git-send-email-aliguori@us.ibm.com> <4D74E01D.9020304@codemonkey.ws> <20110307134610.GP21899@redhat.com> In-Reply-To: <20110307134610.GP21899@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Adam Litke , Stefan Hajnoczi , qemu-devel@nongnu.org, Markus Armbruster , Luiz Capitulino On 03/07/2011 07:46 AM, Daniel P. Berrange wrote: > On Mon, Mar 07, 2011 at 07:39:41AM -0600, Anthony Liguori wrote: > >> On 03/07/2011 07:09 AM, Stefan Hajnoczi wrote: >> >>> On Mon, Mar 7, 2011 at 1:22 AM, Anthony Liguori wrote: >>> >>>> +char *qobject_as_string(QObject *obj) >>>> +{ >>>> + char buffer[1024]; >>>> + >>>> + switch (qobject_type(obj)) { >>>> + case QTYPE_QINT: >>>> + snprintf(buffer, sizeof(buffer), "%" PRId64, >>>> + qint_get_int(qobject_to_qint(obj))); >>>> + return qemu_strdup(buffer); >>>> + case QTYPE_QSTRING: >>>> + return qemu_strdup(qstring_get_str(qobject_to_qstring(obj))); >>>> + case QTYPE_QFLOAT: >>>> + snprintf(buffer, sizeof(buffer), "%.17g", >>>> + qfloat_get_double(qobject_to_qfloat(obj))); >>>> + return qemu_strdup(buffer); >>>> >>> qemu_asprintf() would be a nice helper function to have ;). >>> >> Indeed :-) >> > Since you've introduced glib, you get that function for free: > > g_strdup_printf()/g_strdup_vprintf() > > similarly qemu_strdup& malloc related friends could be replaced with > the equivalent glib functions. > Good point. Regards, Anthony Liguori > Regards, > Daniel >