Re: [libvirt] [PATCH 1/6] Fix virDiskNameToIndex to actually ignore partition numbers

2012-11-23 Thread Martin Kletzander
On 11/22/2012 05:48 PM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The docs for virDiskNameToIndex claim it ignores partition
 numbers. In actual fact though, a code ordering buy means

s/buy/bug/

 that a partition number will cause the code to accidentally
 multiply the result by 26.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/util/util.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
 
 diff --git a/src/util/util.c b/src/util/util.c
 index 75b18c1..2fd0f2c 100644
 --- a/src/util/util.c
 +++ b/src/util/util.c
 @@ -2193,11 +2193,10 @@ int virDiskNameToIndex(const char *name) {
  return -1;
  
  for (i = 0; *ptr; i++) {
 -idx = (idx + (i  1 ? 0 : 1)) * 26;
 -
  if (!c_islower(*ptr))
  break;
  
 +idx = (idx + (i  1 ? 0 : 1)) * 26;
  idx += *ptr - 'a';
  ptr++;
  }
 

ACK,

Martin

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


[libvirt] [PATCH 1/6] Fix virDiskNameToIndex to actually ignore partition numbers

2012-11-22 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The docs for virDiskNameToIndex claim it ignores partition
numbers. In actual fact though, a code ordering buy means
that a partition number will cause the code to accidentally
multiply the result by 26.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/util/util.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 75b18c1..2fd0f2c 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2193,11 +2193,10 @@ int virDiskNameToIndex(const char *name) {
 return -1;
 
 for (i = 0; *ptr; i++) {
-idx = (idx + (i  1 ? 0 : 1)) * 26;
-
 if (!c_islower(*ptr))
 break;
 
+idx = (idx + (i  1 ? 0 : 1)) * 26;
 idx += *ptr - 'a';
 ptr++;
 }
-- 
1.7.11.2

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