|
| From: | Anthony Liguori |
| Subject: | Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes |
| Date: | Mon, 11 Aug 2008 20:57:29 -0500 |
| User-agent: | Thunderbird 2.0.0.16 (X11/20080723) |
Laurent Vivier wrote:
Le lundi 11 août 2008 à 14:22 -0500, Anthony Liguori a écrit :but using "void (*handler)(int argc, char** argv)" avoids the switch: switch(nb_args) { case 0: cmd->handler(); break; case 1: cmd->handler(args[0]); break; ... } becomes cmd->handler(nb_args, args);
And then every monitor command changes from:
void do_eject(int force, char *device)
{
...
}
to:
void do_eject(int argc, char **argv)
{
char *device;
int force = 0;
if (argc == 2) {
if (strcmp(argv[0], "-f") == 0) {
force = 1;
device = argv[1];
} else {
term_printf("bad option %s\n", argv[0]);
return;
}
} else if (argc == 1) {
device = argv[0];
} else {
term_printf("bad number of options\n");
return;
}
...
}
Consider multiplying that by all of the possible monitor commands, and
it's totally not worth it.
Regards, Anthony Liguori
Laurent
| [Prev in Thread] | Current Thread | [Next in Thread] |