From patchwork Wed Jan 12 10:57:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/3] use new path_has_protocol() in bdrv_find_protocol() From: Michael Tokarev X-Patchwork-Id: 78536 Message-Id: <1294829822-27938-3-git-send-email-mjt@msgid.tls.msk.ru> To: qemu-devel@nongnu.org Cc: Michael Tokarev Date: Wed, 12 Jan 2011 13:57:01 +0300 Signed-off-by: Michael Tokarev --- block.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) 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) {