Patchwork [2/3] use new path_has_protocol() in bdrv_find_protocol()

login
register
mail settings
Submitter Michael Tokarev
Date Jan. 12, 2011, 10:57 a.m.
Message ID <1294829822-27938-3-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/78536/
State New
Headers show

Comments

Michael Tokarev - Jan. 12, 2011, 10:57 a.m.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 block.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

Patch

diff --git a/block.c b/block.c
index e5a6f60..42d6ff1 100644
--- a/block.c
+++ b/block.c
@@ -314,7 +314,7 @@  static BlockDriver *find_hdev_driver(const char *filename)
 BlockDriver *bdrv_find_protocol(const char *filename)
 {
     BlockDriver *drv1;
-    char protocol[128];
+    char protocol[MAX_PROTO_LEN+1];
     int len;
     const char *p;
 
@@ -332,14 +332,11 @@  BlockDriver *bdrv_find_protocol(const char *filename)
         return drv1;
     }
 
-    if (!path_has_protocol(filename)) {
+    p = path_has_protocol(filename);
+    if (!p) {
         return bdrv_find_format("file");
     }
-    p = strchr(filename, ':');
-    assert(p != NULL);
     len = p - filename;
-    if (len > sizeof(protocol) - 1)
-        len = sizeof(protocol) - 1;
     memcpy(protocol, filename, len);
     protocol[len] = '\0';
     QLIST_FOREACH(drv1, &bdrv_drivers, list) {