[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmis
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes |
Date: |
Tue, 12 Aug 2008 10:14:46 +0200 |
Le lundi 11 août 2008 à 20:57 -0500, Anthony Liguori a écrit :
> 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;
> }
>
> ...
> }
Yes
> Consider multiplying that by all of the possible monitor commands, and
> it's totally not worth it.
it's cleaner and more flexible...
and from an artistic point of view, it's beautiful ;-)
Laurent
--
----------------- address@hidden ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, (continued)
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Laurent Vivier, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Anthony Liguori, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Avi Kivity, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Anthony Liguori, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Blue Swirl, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Laurent Vivier, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Blue Swirl, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Anthony Liguori, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Laurent Vivier, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Anthony Liguori, 2008/08/11
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes,
Laurent Vivier <=
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Avi Kivity, 2008/08/12
- Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes, Daniel Jacobowitz, 2008/08/12