Re: [PATCH] parsing virsh options is wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 27, 2007 at 07:45:45PM +0900, Saori Fukuta wrote:
> When I specified -t (or -q) option with virsh command, the result is 
> something wrong.
 
> I think the cause is missing a conditional before getopt_long at
> vshParseArgv and add to check whether "o->has_arg" is 1 or not.

Yes, your patch below does look like it is doing the correct thing. I'll
apply it to CVS shortly.

> 
> Index: virsh.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/virsh.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 virsh.c
> --- virsh.c     23 Feb 2007 10:27:53 -0000      1.55
> +++ virsh.c     27 Feb 2007 07:35:28 -0000
> @@ -3344,12 +3344,14 @@ vshParseArgv(vshControl * ctl, int argc,
>                  int sz = strlen(last);
> 
>                  for (o = opt; o->name; o++) {
> -                    if (sz == 2 && *(last + 1) == o->val)
> -                        /* valid virsh short option */
> -                        valid = TRUE;
> -                    else if (sz > 2 && strcmp(o->name, last + 2) == 0)
> -                        /* valid virsh long option */
> -                        valid = TRUE;
> +                    if (o->has_arg == 1){
> +                        if (sz == 2 && *(last + 1) == o->val)
> +                            /* valid virsh short option */
> +                            valid = TRUE;
> +                        else if (sz > 2 && strcmp(o->name, last + 2) == 0)
> +                            /* valid virsh long option */
> +                            valid = TRUE;
> +                    }


Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]