]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix virDiskNameToIndex to actually ignore partition numbers
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 22 Nov 2012 14:56:08 +0000 (14:56 +0000)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 21:34:41 +0000 (16:34 -0500)
The docs for virDiskNameToIndex claim it ignores partition
numbers. In actual fact though, a code ordering bug means
that a partition number will cause the code to accidentally
multiply the result by 26.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 81d6c4defe2b72f34b02884bb78f924165998771)

src/util/util.c

index 28f9ae3365c90145d18d6e93bf4022421f2fc728..8315515293d23e347ecec11e2fcc379df087cec2 100644 (file)
@@ -2157,11 +2157,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++;
     }