1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

network: use virDirRead in networkMigrateStateFiles

This attempts to follow the same variable name and usage patterns as
the other conversions to virDirRead().
This commit is contained in:
Laine Stump 2014-04-28 13:45:15 +03:00 committed by Eric Blake
parent 56a03233ab
commit a431523444

View File

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