[PATCH 3/7] util: Don't miss the slash in constructed path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case of the caller can pass a "prefix" (or "sysfs_prefix")
without the trailing slash, and Unix-Like system always eats
up the redundant "slash" in the filepath, let's add it explicitly.
---
 src/util/virutil.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index ebf902d..da87897 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -3140,7 +3140,7 @@ virIsCapableFCHost(const char *sysfs_prefix,
     char *sysfs_path = NULL;
     int ret = -1;
 
-    if (virAsprintf(&sysfs_path, "%shost%d",
+    if (virAsprintf(&sysfs_path, "%s/host%d",
                     sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
                     host) < 0) {
         virReportOOMError();
@@ -3163,7 +3163,7 @@ virIsCapableVport(const char *sysfs_prefix,
     int ret = -1;
 
     if (virAsprintf(&fc_host_path,
-                    "%shost%d/%s",
+                    "%s/host%d/%s",
                     sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
                     host,
                     "vport_create") < 0) {
@@ -3172,7 +3172,7 @@ virIsCapableVport(const char *sysfs_prefix,
     }
 
     if (virAsprintf(&scsi_host_path,
-                    "%shost%d/%s",
+                    "%s/host%d/%s",
                     sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_PATH,
                     host,
                     "vport_create") < 0) {
@@ -3214,7 +3214,7 @@ virManageVport(const int parent_host,
     }
 
     if (virAsprintf(&operation_path,
-                    "%shost%d/%s",
+                    "%s/host%d/%s",
                     SYSFS_FC_HOST_PATH,
                     parent_host,
                     operation_file) < 0) {
@@ -3225,7 +3225,7 @@ virManageVport(const int parent_host,
     if (!virFileExists(operation_path)) {
         VIR_FREE(operation_path);
         if (virAsprintf(&operation_path,
-                        "%shost%d/%s",
+                        "%s/host%d/%s",
                         SYSFS_SCSI_HOST_PATH,
                         parent_host,
                         operation_file) < 0) {
@@ -3306,7 +3306,7 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
         if (entry->d_name[0] == '.')
             continue;
 
-        if (virAsprintf(&wwnn_path, "%s%s/node_name", prefix,
+        if (virAsprintf(&wwnn_path, "%s/%s/node_name", prefix,
                         entry->d_name) < 0) {
             virReportOOMError();
             goto cleanup;
@@ -3325,7 +3325,7 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
             continue;
         }
 
-        if (virAsprintf(&wwpn_path, "%s%s/port_name", prefix,
+        if (virAsprintf(&wwpn_path, "%s/%s/port_name", prefix,
                         entry->d_name) < 0) {
             virReportOOMError();
             goto cleanup;
-- 
1.8.1.4

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]