[libvirt] [PATCH 03/21] tests: qemuxml2argv: add va_arg enum handling
Andrea Bolognani
abologna at redhat.com
Tue Mar 19 11:36:52 UTC 2019
On Thu, 2019-03-14 at 10:43 -0400, Cole Robinson wrote:
[...]
> +typedef enum {
> + ARG_QEMU_CAPS = 1,
Any specific reason to start from 1 rather than 0, or even leaving
out the start value entirely?
> +
> + ARG_END = QEMU_CAPS_LAST,
> +} testInfoArgNames;
The name of the enum should be singular, otherwise it will look
weird when you declare a variable of the type, like...
> static int
> testInfoSetArgs(struct testInfo *info, ...)
> {
> va_list argptr;
> - int ret = 0;
> + testInfoArgNames argname;
... here.
[...]
> + while ((argname = va_arg(argptr, int)) < ARG_END) {
> + switch (argname) {
I think you should either call va_arg() with testInfoArgNames as the
second argument, or make the argname variable int and then have an
explicit cast in the switch().
[...]
> + case ARG_END:
> + default:
> + fprintf(stderr, "Unexpected test info argument");
> + goto cleanup;
> + }
> + }
> +
> + ret = 0;
One extra empty line here, please.
Reviewed-by: Andrea Bolognani <abologna at redhat.com>
--
Andrea Bolognani / Red Hat / Virtualization
More information about the libvir-list
mailing list