Luiz Capitulino wrote:
 Hi,

 I can't remember seeing updated versions of a RFC series, but this should
prevent Anthony's scripts from merging these patches.

 This new QError version has two major changes: the static error table has
been dropped and I'm using symbolic names instead of error codes.

 Now, a call to:

monitor_printf(mon, "husb: host usb device %d.%d is already open\n",
               bus_num, addr);

 Would become something like:

qemu_error_new('DeviceAlreadyOpen', "{ 'bus_num': %d, 'addr': %d }",
               bus_num, addr);

I mostly like this but this is not what the patches do :-)

Here's what I would like to see:

#define QERR_DEVICE_ALREADY_OPEN "{'class': 'DeviceAlreadyOpen', 'data' : {'bus_num': %d, 'addr': %d}"

qemu_error_new(QERR_DEVICE_ALREADY_OPEN, bus_num, addr);

That gives us a nice simple interface with full error checking on the parameters.

For human readable strings, I'd suggest making a table somewhere else that looked like:

QErrorStringTable qerror_descriptions[] = {
{ QERR_DEVICE_ALREADY_OPEN, "This device at %(bus_num)d.%(addr)d is already open." },
...
};

There are a number of advantages to an approach like this. The table can be reused by both in the server and by a client.

Regards,

Anthony Liguori


Reply via email to