From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MoAeU-0006Jd-4D for qemu-devel@nongnu.org; Thu, 17 Sep 2009 02:39:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MoAeP-0006HN-0j for qemu-devel@nongnu.org; Thu, 17 Sep 2009 02:39:33 -0400 Received: from [199.232.76.173] (port=51891 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MoAeO-0006Gv-O6 for qemu-devel@nongnu.org; Thu, 17 Sep 2009 02:39:28 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:48379) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MoAeO-0006dr-Ct for qemu-devel@nongnu.org; Thu, 17 Sep 2009 02:39:28 -0400 Received: by fxm7 with SMTP id 7so3943932fxm.34 for ; Wed, 16 Sep 2009 23:39:27 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4AB1D99D.5080007@gnu.org> Date: Thu, 17 Sep 2009 08:39:25 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1253136760-3614-1-git-send-email-lcapitulino@redhat.com> <1253136760-3614-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1253136760-3614-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 2/7] monitor: Handle new and old style handlers List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel On 09/16/2009 11:32 PM, Luiz Capitulino wrote: > + return (cmd->user_print == NULL ? 0 : 1); cmd->user_print != NULL. I would actually inline it at the use point. Also, calling a function with an extra argument is fine, so while keeping the void* handler you can do: + QObject *data = NULL; + int (*handler_new)(Monitor *mon, + const QDict *params, QObject **ret_data); + handler_new = cmd->handler; + handler_new(mon, qdict, &data); + if (cmd->user_print) + cmd->user_print(mon, data); + if (data) + qobject_decref(data); If you do not like calling the function with the "wrong" number of arguments, you can mass-convert the functions to the new prototype new and leave anyway user_print == NULL. What are the plans for the return code of handler_new? Paolo