qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers


From: Paolo Bonzini
Subject: [Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers
Date: Thu, 17 Sep 2009 08:39:25 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3

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




reply via email to

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