Re: [PATCH] tools: fix a judgment of equalling zero about an array's length

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

 




> -----Original Message-----
> From: libvir-list-bounces@xxxxxxxxxx
[mailto:libvir-list-bounces@xxxxxxxxxx]
> On Behalf Of lawrancejing
> Sent: Friday, September 13, 2013 10:00 AM
> To: libvir-list@xxxxxxxxxx
> Cc: lawrancejing
> Subject:  [PATCH] tools: fix a judgment of equalling zero about
an array's
> length
> 
> There is no need to go on executing code when the array's length is zero.
> ---
>  tools/virsh-snapshot.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
> index e37a5b3..d7a4c7b 100644
> --- a/tools/virsh-snapshot.c
> +++ b/tools/virsh-snapshot.c
> @@ -239,7 +239,7 @@ vshParseSnapshotMemspec(vshControl *ctl,
> virBufferPtr buf, const char *str)
>          return 0;
> 
>      narray = vshStringToArray(str, &array);

If str is NULL, we could get a array sized 1(a NULL element at the end), or
some 
negative values if error occurred.

So don't worry about 0 would return from vshStringToArray. 

> -    if (narray < 0)
> +    if (narray <= 0)
>          goto cleanup;
> 
>      for (i = 0; i < narray; i++) {
> --
> 1.7.1
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]