[PATCHv2 6.5/7] network: use virDirRead in networkMigrateStateFiles

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

 



This attempts to follow the same variable name and usage patterns as
the other conversions to virDirRead().
---
 src/network/bridge_driver.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 4e8375d..5233833 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -463,6 +463,7 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver)
     int ret = -1;
     const char *oldStateDir = LOCALSTATEDIR "/lib/libvirt/network";
     DIR *dir;
+    int direrr;
     struct dirent *entry;
     char *oldPath = NULL, *newPath = NULL;
     char *contents = NULL;
@@ -482,17 +483,7 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver)
         goto cleanup;
     }
 
-    for (;;) {
-        errno = 0;
-        entry = readdir(dir);
-        if (!entry) {
-            if (errno) {
-                virReportSystemError(errno, _("failed to read directory '%s'"),
-                                     oldStateDir);
-                goto cleanup;
-            }
-            break;
-        }
+    while ((direrr = virDirRead(dir, &entry, oldStateDir)) > 0) {
 
         if (entry->d_type != DT_REG ||
             STREQ(entry->d_name, ".") ||
@@ -520,6 +511,8 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver)
         VIR_FREE(newPath);
         VIR_FREE(contents);
     }
+    if (direrr < 0)
+       goto cleanup;
 
     ret = 0;
  cleanup:
-- 
1.9.0

--
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]