mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 13:35:17 +00:00
locking: prefer g_new0 to VIR_ALLOC
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
97a6a5b145
commit
4c6f98cea6
@ -120,8 +120,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
|
|||||||
virLockDaemonPtr lockd;
|
virLockDaemonPtr lockd;
|
||||||
virNetServerPtr srv = NULL;
|
virNetServerPtr srv = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(lockd) < 0)
|
lockd = g_new0(virLockDaemon, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
g_mutex_init(&lockd->lock);
|
g_mutex_init(&lockd->lock);
|
||||||
|
|
||||||
@ -212,8 +211,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
|
|||||||
size_t i;
|
size_t i;
|
||||||
const char *serverNames[] = { "virtlockd" };
|
const char *serverNames[] = { "virtlockd" };
|
||||||
|
|
||||||
if (VIR_ALLOC(lockd) < 0)
|
lockd = g_new0(virLockDaemon, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
g_mutex_init(&lockd->lock);
|
g_mutex_init(&lockd->lock);
|
||||||
|
|
||||||
@ -456,8 +454,7 @@ virLockDaemonClientNew(virNetServerClientPtr client,
|
|||||||
unsigned long long timestamp;
|
unsigned long long timestamp;
|
||||||
bool privileged = opaque != NULL;
|
bool privileged = opaque != NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(priv) < 0)
|
priv = g_new0(virLockDaemonClient, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
g_mutex_init(&priv->lock);
|
g_mutex_init(&priv->lock);
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ virLockDaemonConfigNew(bool privileged G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockDaemonConfigPtr data;
|
virLockDaemonConfigPtr data;
|
||||||
|
|
||||||
if (VIR_ALLOC(data) < 0)
|
data = g_new0(virLockDaemonConfig, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
data->max_clients = 1024;
|
data->max_clients = 1024;
|
||||||
data->admin_max_clients = 5000;
|
data->admin_max_clients = 5000;
|
||||||
|
@ -316,8 +316,7 @@ static int virLockManagerLockDaemonInit(unsigned int version,
|
|||||||
if (driver)
|
if (driver)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
driver = g_new0(virLockManagerLockDaemonDriver, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
driver->requireLeaseForDisks = true;
|
driver->requireLeaseForDisks = true;
|
||||||
driver->autoDiskLease = true;
|
driver->autoDiskLease = true;
|
||||||
@ -399,8 +398,8 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
|
|||||||
|
|
||||||
virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
|
virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
|
||||||
|
|
||||||
if (VIR_ALLOC(priv) < 0)
|
priv = g_new0(virLockManagerLockDaemonPrivate,
|
||||||
return -1;
|
1);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN:
|
case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN:
|
||||||
|
@ -397,8 +397,7 @@ static int virLockManagerSanlockInit(unsigned int version,
|
|||||||
if (sanlockDriver)
|
if (sanlockDriver)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(sanlockDriver) < 0)
|
sanlockDriver = g_new0(virLockManagerSanlockDriver, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
driver = sanlockDriver;
|
driver = sanlockDriver;
|
||||||
|
|
||||||
@ -468,8 +467,8 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(priv) < 0)
|
priv = g_new0(virLockManagerSanlockPrivate,
|
||||||
return -1;
|
1);
|
||||||
|
|
||||||
priv->flags = flags;
|
priv->flags = flags;
|
||||||
|
|
||||||
@ -937,8 +936,7 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(opt) < 0)
|
opt = g_new0(struct sanlk_options, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* sanlock doesn't use owner_name for anything, so it's safe to take just
|
/* sanlock doesn't use owner_name for anything, so it's safe to take just
|
||||||
* the first SANLK_NAME_LEN - 1 characters from vm_name */
|
* the first SANLK_NAME_LEN - 1 characters from vm_name */
|
||||||
|
@ -171,8 +171,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, configFile, flags) < 0)
|
if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, configFile, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC(plugin) < 0)
|
plugin = g_new0(virLockManagerPlugin, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
plugin->driver = driver;
|
plugin->driver = driver;
|
||||||
plugin->handle = handle;
|
plugin->handle = handle;
|
||||||
@ -303,8 +302,7 @@ virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
|
|||||||
|
|
||||||
CHECK_DRIVER(drvNew, NULL);
|
CHECK_DRIVER(drvNew, NULL);
|
||||||
|
|
||||||
if (VIR_ALLOC(lock) < 0)
|
lock = g_new0(virLockManager, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
lock->driver = driver;
|
lock->driver = driver;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user