mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
Replace 'goto cleanup' with 'goto error' in udev interface driver
Some methods in the udev interface driver used 'cleanup' as the label for separate error codepaths. Change these to use 'error' as required by coding standards Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
5af5c28bbb
commit
dc34fc16be
@ -565,13 +565,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/downdelay' for '%s'"), name);
|
_("Could not retrieve 'bonding/downdelay' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/downdelay' '%s' for '%s'"),
|
_("Could not parse 'bonding/downdelay' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.downdelay = tmp_int;
|
ifacedef->data.bond.downdelay = tmp_int;
|
||||||
|
|
||||||
@ -579,13 +579,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/updelay' for '%s'"), name);
|
_("Could not retrieve 'bonding/updelay' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/updelay' '%s' for '%s'"),
|
_("Could not parse 'bonding/updelay' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.updelay = tmp_int;
|
ifacedef->data.bond.updelay = tmp_int;
|
||||||
|
|
||||||
@ -593,13 +593,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/miimon' for '%s'"), name);
|
_("Could not retrieve 'bonding/miimon' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/miimon' '%s' for '%s'"),
|
_("Could not parse 'bonding/miimon' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.frequency = tmp_int;
|
ifacedef->data.bond.frequency = tmp_int;
|
||||||
|
|
||||||
@ -607,13 +607,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/arp_interval' for '%s'"), name);
|
_("Could not retrieve 'bonding/arp_interval' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/arp_interval' '%s' for '%s'"),
|
_("Could not parse 'bonding/arp_interval' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.interval = tmp_int;
|
ifacedef->data.bond.interval = tmp_int;
|
||||||
|
|
||||||
@ -626,25 +626,25 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/mode' for '%s'"), name);
|
_("Could not retrieve 'bonding/mode' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
tmp_str = strchr(tmp_str, ' ');
|
tmp_str = strchr(tmp_str, ' ');
|
||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid format for 'bonding/mode' for '%s'"), name);
|
_("Invalid format for 'bonding/mode' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (strlen(tmp_str) < 2) {
|
if (strlen(tmp_str) < 2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find correct value in 'bonding/mode' for '%s'"),
|
_("Unable to find correct value in 'bonding/mode' for '%s'"),
|
||||||
name);
|
name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/mode' '%s' for '%s'"),
|
_("Could not parse 'bonding/mode' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.mode = tmp_int + 1;
|
ifacedef->data.bond.mode = tmp_int + 1;
|
||||||
|
|
||||||
@ -656,25 +656,25 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/arp_validate' for '%s'"), name);
|
_("Could not retrieve 'bonding/arp_validate' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
tmp_str = strchr(tmp_str, ' ');
|
tmp_str = strchr(tmp_str, ' ');
|
||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid format for 'bonding/arp_validate' for '%s'"), name);
|
_("Invalid format for 'bonding/arp_validate' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (strlen(tmp_str) < 2) {
|
if (strlen(tmp_str) < 2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find correct value in 'bonding/arp_validate' "
|
_("Unable to find correct value in 'bonding/arp_validate' "
|
||||||
"for '%s'"), name);
|
"for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/arp_validate' '%s' for '%s'"),
|
_("Could not parse 'bonding/arp_validate' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.validate = tmp_int;
|
ifacedef->data.bond.validate = tmp_int;
|
||||||
|
|
||||||
@ -683,13 +683,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/use_carrier' for '%s'"), name);
|
_("Could not retrieve 'bonding/use_carrier' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse 'bonding/use_carrier' '%s' for '%s'"),
|
_("Could not parse 'bonding/use_carrier' '%s' for '%s'"),
|
||||||
tmp_str, name);
|
tmp_str, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.carrier = tmp_int + 1;
|
ifacedef->data.bond.carrier = tmp_int + 1;
|
||||||
|
|
||||||
@ -708,10 +708,10 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (!tmp_str) {
|
if (!tmp_str) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not retrieve 'bonding/arp_ip_target' for '%s'"), name);
|
_("Could not retrieve 'bonding/arp_ip_target' for '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0)
|
if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
|
|
||||||
/* Slaves of the bond */
|
/* Slaves of the bond */
|
||||||
/* Get each slave in the bond */
|
/* Get each slave in the bond */
|
||||||
@ -721,13 +721,13 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
if (slave_count < 0) {
|
if (slave_count < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Could not get slaves of bond '%s'"), name);
|
_("Could not get slaves of bond '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate our list of slave devices */
|
/* Allocate our list of slave devices */
|
||||||
if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0) {
|
if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->data.bond.nbItf = slave_count;
|
ifacedef->data.bond.nbItf = slave_count;
|
||||||
|
|
||||||
@ -740,7 +740,7 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid enslaved interface name '%s' seen for "
|
_("Invalid enslaved interface name '%s' seen for "
|
||||||
"bond '%s'"), slave_list[i]->d_name, name);
|
"bond '%s'"), slave_list[i]->d_name, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
/* go past the _ */
|
/* go past the _ */
|
||||||
tmp_str++;
|
tmp_str++;
|
||||||
@ -751,7 +751,7 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get interface information for '%s', which is "
|
_("Could not get interface information for '%s', which is "
|
||||||
"a enslaved in bond '%s'"), slave_list[i]->d_name, name);
|
"a enslaved in bond '%s'"), slave_list[i]->d_name, name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(slave_list[i]);
|
VIR_FREE(slave_list[i]);
|
||||||
}
|
}
|
||||||
@ -760,7 +760,7 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
error:
|
||||||
for (i = 0; i < slave_count; i++) {
|
for (i = 0; i < slave_count; i++) {
|
||||||
VIR_FREE(slave_list[i]);
|
VIR_FREE(slave_list[i]);
|
||||||
}
|
}
|
||||||
@ -901,14 +901,14 @@ udevGetIfaceDefVlan(struct udev *udev ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
/* Set the VLAN specifics */
|
/* Set the VLAN specifics */
|
||||||
if (VIR_STRDUP(ifacedef->data.vlan.tag, vid + 1) < 0)
|
if (VIR_STRDUP(ifacedef->data.vlan.tag, vid + 1) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
if (VIR_STRNDUP(ifacedef->data.vlan.devname,
|
if (VIR_STRNDUP(ifacedef->data.vlan.devname,
|
||||||
name, (vid - name)) < 0)
|
name, (vid - name)) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
error:
|
||||||
VIR_FREE(ifacedef->data.vlan.tag);
|
VIR_FREE(ifacedef->data.vlan.tag);
|
||||||
VIR_FREE(ifacedef->data.vlan.devname);
|
VIR_FREE(ifacedef->data.vlan.devname);
|
||||||
|
|
||||||
@ -934,27 +934,27 @@ udevGetIfaceDef(struct udev *udev, const char *name)
|
|||||||
/* Clear our structure and set safe defaults */
|
/* Clear our structure and set safe defaults */
|
||||||
ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
|
ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
|
||||||
if (VIR_STRDUP(ifacedef->name, name) < 0)
|
if (VIR_STRDUP(ifacedef->name, name) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
|
|
||||||
/* Lookup the device we've been asked about */
|
/* Lookup the device we've been asked about */
|
||||||
dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
|
dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
virReportError(VIR_ERR_NO_INTERFACE,
|
virReportError(VIR_ERR_NO_INTERFACE,
|
||||||
_("couldn't find interface named '%s'"), name);
|
_("couldn't find interface named '%s'"), name);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MAC address */
|
/* MAC address */
|
||||||
if (VIR_STRDUP(ifacedef->mac,
|
if (VIR_STRDUP(ifacedef->mac,
|
||||||
udev_device_get_sysattr_value(dev, "address")) < 0)
|
udev_device_get_sysattr_value(dev, "address")) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
|
|
||||||
/* MTU */
|
/* MTU */
|
||||||
mtu_str = udev_device_get_sysattr_value(dev, "mtu");
|
mtu_str = udev_device_get_sysattr_value(dev, "mtu");
|
||||||
if (virStrToLong_ui(mtu_str, NULL, 10, &mtu) < 0) {
|
if (virStrToLong_ui(mtu_str, NULL, 10, &mtu) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse MTU value '%s'"), mtu_str);
|
_("Could not parse MTU value '%s'"), mtu_str);
|
||||||
goto cleanup;
|
goto error;
|
||||||
}
|
}
|
||||||
ifacedef->mtu = mtu;
|
ifacedef->mtu = mtu;
|
||||||
|
|
||||||
@ -1000,15 +1000,15 @@ udevGetIfaceDef(struct udev *udev, const char *name)
|
|||||||
switch (ifacedef->type) {
|
switch (ifacedef->type) {
|
||||||
case VIR_INTERFACE_TYPE_VLAN:
|
case VIR_INTERFACE_TYPE_VLAN:
|
||||||
if (udevGetIfaceDefVlan(udev, dev, name, ifacedef) < 0)
|
if (udevGetIfaceDefVlan(udev, dev, name, ifacedef) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BRIDGE:
|
case VIR_INTERFACE_TYPE_BRIDGE:
|
||||||
if (udevGetIfaceDefBridge(udev, dev, name, ifacedef) < 0)
|
if (udevGetIfaceDefBridge(udev, dev, name, ifacedef) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BOND:
|
case VIR_INTERFACE_TYPE_BOND:
|
||||||
if (udevGetIfaceDefBond(udev, dev, name, ifacedef) < 0)
|
if (udevGetIfaceDefBond(udev, dev, name, ifacedef) < 0)
|
||||||
goto cleanup;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_ETHERNET:
|
case VIR_INTERFACE_TYPE_ETHERNET:
|
||||||
break;
|
break;
|
||||||
@ -1018,7 +1018,7 @@ udevGetIfaceDef(struct udev *udev, const char *name)
|
|||||||
|
|
||||||
return ifacedef;
|
return ifacedef;
|
||||||
|
|
||||||
cleanup:
|
error:
|
||||||
udev_device_unref(dev);
|
udev_device_unref(dev);
|
||||||
|
|
||||||
virInterfaceDefFree(ifacedef);
|
virInterfaceDefFree(ifacedef);
|
||||||
|
Loading…
Reference in New Issue
Block a user