mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +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;
|
||||
virNetServerPtr srv = NULL;
|
||||
|
||||
if (VIR_ALLOC(lockd) < 0)
|
||||
return NULL;
|
||||
lockd = g_new0(virLockDaemon, 1);
|
||||
|
||||
g_mutex_init(&lockd->lock);
|
||||
|
||||
@ -212,8 +211,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
|
||||
size_t i;
|
||||
const char *serverNames[] = { "virtlockd" };
|
||||
|
||||
if (VIR_ALLOC(lockd) < 0)
|
||||
return NULL;
|
||||
lockd = g_new0(virLockDaemon, 1);
|
||||
|
||||
g_mutex_init(&lockd->lock);
|
||||
|
||||
@ -456,8 +454,7 @@ virLockDaemonClientNew(virNetServerClientPtr client,
|
||||
unsigned long long timestamp;
|
||||
bool privileged = opaque != NULL;
|
||||
|
||||
if (VIR_ALLOC(priv) < 0)
|
||||
return NULL;
|
||||
priv = g_new0(virLockDaemonClient, 1);
|
||||
|
||||
g_mutex_init(&priv->lock);
|
||||
|
||||
|
@ -57,8 +57,7 @@ virLockDaemonConfigNew(bool privileged G_GNUC_UNUSED)
|
||||
{
|
||||
virLockDaemonConfigPtr data;
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
return NULL;
|
||||
data = g_new0(virLockDaemonConfig, 1);
|
||||
|
||||
data->max_clients = 1024;
|
||||
data->admin_max_clients = 5000;
|
||||
|
@ -316,8 +316,7 @@ static int virLockManagerLockDaemonInit(unsigned int version,
|
||||
if (driver)
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC(driver) < 0)
|
||||
return -1;
|
||||
driver = g_new0(virLockManagerLockDaemonDriver, 1);
|
||||
|
||||
driver->requireLeaseForDisks = true;
|
||||
driver->autoDiskLease = true;
|
||||
@ -399,8 +398,8 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
|
||||
|
||||
virCheckFlags(VIR_LOCK_MANAGER_NEW_STARTED, -1);
|
||||
|
||||
if (VIR_ALLOC(priv) < 0)
|
||||
return -1;
|
||||
priv = g_new0(virLockManagerLockDaemonPrivate,
|
||||
1);
|
||||
|
||||
switch (type) {
|
||||
case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN:
|
||||
|
@ -397,8 +397,7 @@ static int virLockManagerSanlockInit(unsigned int version,
|
||||
if (sanlockDriver)
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC(sanlockDriver) < 0)
|
||||
return -1;
|
||||
sanlockDriver = g_new0(virLockManagerSanlockDriver, 1);
|
||||
|
||||
driver = sanlockDriver;
|
||||
|
||||
@ -468,8 +467,8 @@ static int virLockManagerSanlockNew(virLockManagerPtr lock,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(priv) < 0)
|
||||
return -1;
|
||||
priv = g_new0(virLockManagerSanlockPrivate,
|
||||
1);
|
||||
|
||||
priv->flags = flags;
|
||||
|
||||
@ -937,8 +936,7 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(opt) < 0)
|
||||
goto error;
|
||||
opt = g_new0(struct sanlk_options, 1);
|
||||
|
||||
/* 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 */
|
||||
|
@ -171,8 +171,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
||||
if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, configFile, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (VIR_ALLOC(plugin) < 0)
|
||||
goto cleanup;
|
||||
plugin = g_new0(virLockManagerPlugin, 1);
|
||||
|
||||
plugin->driver = driver;
|
||||
plugin->handle = handle;
|
||||
@ -303,8 +302,7 @@ virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
|
||||
|
||||
CHECK_DRIVER(drvNew, NULL);
|
||||
|
||||
if (VIR_ALLOC(lock) < 0)
|
||||
return NULL;
|
||||
lock = g_new0(virLockManager, 1);
|
||||
|
||||
lock->driver = driver;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user