]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
parallels: cleanup parallelsOpen and fix error message
authorDmitry Guryanov <dguryanov@parallels.com>
Mon, 13 Aug 2012 15:50:13 +0000 (19:50 +0400)
committerDaniel Veillard <veillard@redhat.com>
Wed, 15 Aug 2012 08:39:36 +0000 (16:39 +0800)
Do some cleanup of parallelsOpen, STREQ_NULLABLE can replace
a lot of checks.

Also fix error message to be VIR_ERR_INTERNAL_ERROR, the same
as in other drivers.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
src/parallels/parallels_driver.c

index b5e079112252122b8f974ca9f5f384792be84ddf..06a75b353d82f2996976e25407e60246b89c770e 100644 (file)
@@ -664,21 +664,14 @@ parallelsOpen(virConnectPtr conn,
         return VIR_DRV_OPEN_DECLINED;
 
     /* From this point on, the connection is for us. */
-    if (
-        conn->uri->path[0] == '\0' ||
-        (conn->uri->path[0] == '/' && conn->uri->path[1] == '\0')) {
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("parallelsOpen: supply a path or use "
-                         "parallels:///system"));
+    if (!STREQ_NULLABLE(conn->uri->path, "/system")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Unexpected Parallels URI path '%s', try parallels:///system"),
+                       conn->uri->path);
         return VIR_DRV_OPEN_ERROR;
     }
 
-    if (STREQ(conn->uri->path, "/system"))
-        ret = parallelsOpenDefault(conn);
-    else
-        return VIR_DRV_OPEN_DECLINED;
-
-    if (ret != VIR_DRV_OPEN_SUCCESS)
+    if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS)
         return ret;
 
     return VIR_DRV_OPEN_SUCCESS;