提交 39ad0001 编写于 作者: H Hu Tao 提交者: Eric Blake

build: more fix to avoid C99 for loop

see commit 7e5aa78d

* src/interface/interface_backend_udev.c: Declare variable sooner.
上级 89cf3630
...@@ -515,12 +515,14 @@ udevIfaceScanDirFilter(const struct dirent *entry) ...@@ -515,12 +515,14 @@ udevIfaceScanDirFilter(const struct dirent *entry)
static void static void
udevIfaceFreeIfaceDef(virInterfaceDef *ifacedef) udevIfaceFreeIfaceDef(virInterfaceDef *ifacedef)
{ {
int i;
if (!ifacedef) if (!ifacedef)
return; return;
if (ifacedef->type == VIR_INTERFACE_TYPE_BRIDGE) { if (ifacedef->type == VIR_INTERFACE_TYPE_BRIDGE) {
VIR_FREE(ifacedef->data.bridge.delay); VIR_FREE(ifacedef->data.bridge.delay);
for (int i = 0; i < ifacedef->data.bridge.nbItf; i++) { for (i = 0; i < ifacedef->data.bridge.nbItf; i++) {
udevIfaceFreeIfaceDef(ifacedef->data.bridge.itf[i]); udevIfaceFreeIfaceDef(ifacedef->data.bridge.itf[i]);
} }
VIR_FREE(ifacedef->data.bridge.itf); VIR_FREE(ifacedef->data.bridge.itf);
...@@ -547,6 +549,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name) ...@@ -547,6 +549,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name)
char *vlan_parent_dev = NULL; char *vlan_parent_dev = NULL;
struct dirent **member_list = NULL; struct dirent **member_list = NULL;
int member_count = 0; int member_count = 0;
int i;
/* Allocate our interface definition structure */ /* Allocate our interface definition structure */
if (VIR_ALLOC(ifacedef) < 0) { if (VIR_ALLOC(ifacedef) < 0) {
...@@ -679,7 +682,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name) ...@@ -679,7 +682,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name)
} }
ifacedef->data.bridge.nbItf = member_count; ifacedef->data.bridge.nbItf = member_count;
for (int i= 0; i < member_count; i++) { for (i = 0; i < member_count; i++) {
ifacedef->data.bridge.itf[i] = ifacedef->data.bridge.itf[i] =
udevIfaceGetIfaceDef(udev, member_list[i]->d_name); udevIfaceGetIfaceDef(udev, member_list[i]->d_name);
VIR_FREE(member_list[i]); VIR_FREE(member_list[i]);
...@@ -698,7 +701,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name) ...@@ -698,7 +701,7 @@ udevIfaceGetIfaceDef(struct udev *udev, char *name)
cleanup: cleanup:
udev_device_unref(dev); udev_device_unref(dev);
for (int i = 0; i < member_count; i++) { for (i = 0; i < member_count; i++) {
VIR_FREE(member_list[i]); VIR_FREE(member_list[i]);
} }
VIR_FREE(member_list); VIR_FREE(member_list);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册