static int virNetDevVethExists(int devNum)
{
int ret;
- char *path = NULL;
+ VIR_AUTOFREE(char *) path = NULL;
+
if (virAsprintf(&path, SYSFS_NET_DIR "vnet%d/", devNum) < 0)
return -1;
ret = virFileExists(path) ? 1 : 0;
VIR_DEBUG("Checked dev vnet%d usage: %d", devNum, ret);
- VIR_FREE(path);
return ret;
}
int virNetDevVethCreate(char** veth1, char** veth2)
{
int ret = -1;
- char *veth1auto = NULL;
- char *veth2auto = NULL;
int vethNum = 0;
virCommandPtr cmd = NULL;
size_t i;
#define MAX_VETH_RETRIES 10
for (i = 0; i < MAX_VETH_RETRIES; i++) {
+ VIR_AUTOFREE(char *) veth1auto = NULL;
+ VIR_AUTOFREE(char *) veth2auto = NULL;
+
int status;
if (!*veth1) {
int veth1num;
*veth1 ? *veth1 : veth1auto,
*veth2 ? *veth2 : veth2auto,
status);
- VIR_FREE(veth1auto);
- VIR_FREE(veth2auto);
virCommandFree(cmd);
cmd = NULL;
}
cleanup:
virMutexUnlock(&virNetDevVethCreateMutex);
virCommandFree(cmd);
- VIR_FREE(veth1auto);
- VIR_FREE(veth2auto);
return ret;
}