On 8/3/19 7:42 AM, Richard W.M. Jones wrote:
For example nbd_set_debug takes a callback function. Previously this was defined explicitly inside the function parameters. This commit defines a new public typedef:
typedef int (*nbd_debug_callback) (unsigned valid_flag, void *user_data, const char *context, const char *msg);
and then uses the typedef like this:
extern int nbd_set_debug_callback (struct nbd_handle *h, nbd_debug_callback debug_callback, void *debug_callback_user_data);
(Previously typedefs were available, but they were written by hand and only used internally to the library.)
Yes, that aids legibility.
This change necessitates that we uniquely name all of our closures across methods (the same-named closure is required to have the same cbargs).
I took this opportunity to rename some, so especially completion callbacks now have the type nbd_completion_callback. The generator also checks they are named uniquely.
This does not change the C API or ABI.
Concur. The patch looks good to me. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org