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

2013-09-13 Thread Eric Blake
On 09/12/2013 12:12 AM, lawrancejing wrote:
 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(-)

Looks like the mail queue is being flushed, and that this was sent
twice; just in case you missed it on the other message, I don't see how
this patch does anything useful.

 
 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 (narray  0)
 +if (narray = 0)
  goto cleanup;
  
  for (i = 0; i  narray; i++) {
 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2013-09-13 Thread Chen Hanxiao


 -Original Message-
 From: libvir-list-boun...@redhat.com
[mailto:libvir-list-boun...@redhat.com]
 On Behalf Of lawrancejing
 Sent: Friday, September 13, 2013 10:00 AM
 To: libvir-list@redhat.com
 Cc: lawrancejing
 Subject: [libvirt] [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@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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


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

2013-09-12 Thread Eric Blake
On 09/12/2013 08:00 PM, lawrancejing wrote:
 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 (narray  0)
 +if (narray = 0)
  goto cleanup;

Makes no difference.  narray == 0 is not a possible return value from
vshStringToArray, which always returns -1 or a positive number.
Therefore, I don't see the need to apply this.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list