]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: use virDirRead in networkMigrateStateFiles
authorLaine Stump <laine@laine.org>
Mon, 28 Apr 2014 10:45:15 +0000 (13:45 +0300)
committerEric Blake <eblake@redhat.com>
Mon, 28 Apr 2014 23:52:46 +0000 (17:52 -0600)
This attempts to follow the same variable name and usage patterns as
the other conversions to virDirRead().

src/network/bridge_driver.c

index 4e8375dafb34a4bffa32b76ead6763838f834f49..523383374b46398b8c8b682551769a70f164bae5 100644 (file)
@@ -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: