mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: use zalloc
Some places forget to use zalloc().
This commit is contained in:
parent
fc479b2b07
commit
44aeb6d6b8
@ -17,6 +17,7 @@
|
|||||||
#include "link_mon.h"
|
#include "link_mon.h"
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "lib/mm/xlate.h"
|
#include "lib/mm/xlate.h"
|
||||||
|
#include "base/memory/zalloc.h"
|
||||||
|
|
||||||
/* FIXME: remove this and the code */
|
/* FIXME: remove this and the code */
|
||||||
#define CMIRROR_HAS_CHECKPOINT 0
|
#define CMIRROR_HAS_CHECKPOINT 0
|
||||||
@ -402,13 +403,12 @@ static struct checkpoint_data *prepare_checkpoint(struct clog_cpg *entry,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = malloc(sizeof(*new));
|
new = zalloc(sizeof(*new));
|
||||||
if (!new) {
|
if (!new) {
|
||||||
LOG_ERROR("Unable to create checkpoint data for %u",
|
LOG_ERROR("Unable to create checkpoint data for %u",
|
||||||
cp_requester);
|
cp_requester);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(new, 0, sizeof(*new));
|
|
||||||
new->requester = cp_requester;
|
new->requester = cp_requester;
|
||||||
strncpy(new->uuid, entry->name.value, entry->name.length);
|
strncpy(new->uuid, entry->name.value, entry->name.length);
|
||||||
|
|
||||||
@ -643,13 +643,12 @@ static int export_checkpoint(struct checkpoint_data *cp)
|
|||||||
rq_size += RECOVERING_REGION_SECTION_SIZE;
|
rq_size += RECOVERING_REGION_SECTION_SIZE;
|
||||||
rq_size += cp->bitmap_size * 2; /* clean|sync_bits */
|
rq_size += cp->bitmap_size * 2; /* clean|sync_bits */
|
||||||
|
|
||||||
rq = malloc(rq_size);
|
rq = zalloc(rq_size);
|
||||||
if (!rq) {
|
if (!rq) {
|
||||||
LOG_ERROR("export_checkpoint: "
|
LOG_ERROR("export_checkpoint: "
|
||||||
"Unable to allocate transfer structs");
|
"Unable to allocate transfer structs");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(rq, 0, rq_size);
|
|
||||||
|
|
||||||
dm_list_init(&rq->u.list);
|
dm_list_init(&rq->u.list);
|
||||||
rq->u_rq.request_type = DM_ULOG_CHECKPOINT_READY;
|
rq->u_rq.request_type = DM_ULOG_CHECKPOINT_READY;
|
||||||
@ -1621,12 +1620,11 @@ int create_cluster_cpg(char *uuid, uint64_t luid)
|
|||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = malloc(sizeof(*new));
|
new = zalloc(sizeof(*new));
|
||||||
if (!new) {
|
if (!new) {
|
||||||
LOG_ERROR("Unable to allocate memory for clog_cpg");
|
LOG_ERROR("Unable to allocate memory for clog_cpg");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(new, 0, sizeof(*new));
|
|
||||||
dm_list_init(&new->list);
|
dm_list_init(&new->list);
|
||||||
new->lowest_id = 0xDEAD;
|
new->lowest_id = 0xDEAD;
|
||||||
dm_list_init(&new->startup_list);
|
dm_list_init(&new->startup_list);
|
||||||
|
@ -405,12 +405,11 @@ struct lockspace *alloc_lockspace(void)
|
|||||||
{
|
{
|
||||||
struct lockspace *ls;
|
struct lockspace *ls;
|
||||||
|
|
||||||
if (!(ls = malloc(sizeof(struct lockspace)))) {
|
if (!(ls = zalloc(sizeof(struct lockspace)))) {
|
||||||
log_error("out of memory for lockspace");
|
log_error("out of memory for lockspace");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(ls, 0, sizeof(struct lockspace));
|
|
||||||
INIT_LIST_HEAD(&ls->actions);
|
INIT_LIST_HEAD(&ls->actions);
|
||||||
INIT_LIST_HEAD(&ls->resources);
|
INIT_LIST_HEAD(&ls->resources);
|
||||||
pthread_mutex_init(&ls->mutex, NULL);
|
pthread_mutex_init(&ls->mutex, NULL);
|
||||||
|
@ -272,10 +272,9 @@ static int lm_add_resource_dlm(struct lockspace *ls, struct resource *r, int wit
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
|
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
|
||||||
buf = malloc(sizeof(struct val_blk) + DLM_LVB_LEN);
|
buf = zalloc(sizeof(struct val_blk) + DLM_LVB_LEN);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memset(buf, 0, sizeof(struct val_blk) + DLM_LVB_LEN);
|
|
||||||
|
|
||||||
rdd->vb = (struct val_blk *)buf;
|
rdd->vb = (struct val_blk *)buf;
|
||||||
rdd->lksb.sb_lvbptr = buf + sizeof(struct val_blk);
|
rdd->lksb.sb_lvbptr = buf + sizeof(struct val_blk);
|
||||||
|
@ -1393,7 +1393,7 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
lms = malloc(sizeof(struct lm_sanlock));
|
lms = zalloc(sizeof(struct lm_sanlock));
|
||||||
if (!lms) {
|
if (!lms) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -1402,7 +1402,6 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
|||||||
memset(lsname, 0, sizeof(lsname));
|
memset(lsname, 0, sizeof(lsname));
|
||||||
strncpy(lsname, ls->name, SANLK_NAME_LEN);
|
strncpy(lsname, ls->name, SANLK_NAME_LEN);
|
||||||
|
|
||||||
memset(lms, 0, sizeof(struct lm_sanlock));
|
|
||||||
memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);
|
memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);
|
||||||
lms->ss.host_id_disk.offset = 0;
|
lms->ss.host_id_disk.offset = 0;
|
||||||
lms->ss.host_id = ls->host_id;
|
lms->ss.host_id = ls->host_id;
|
||||||
@ -1615,10 +1614,9 @@ static int lm_add_resource_sanlock(struct lockspace *ls, struct resource *r)
|
|||||||
/* LD_RT_LV offset is set in each lm_lock call from lv_args. */
|
/* LD_RT_LV offset is set in each lm_lock call from lv_args. */
|
||||||
|
|
||||||
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
|
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
|
||||||
rds->vb = malloc(sizeof(struct val_blk));
|
rds->vb = zalloc(sizeof(struct val_blk));
|
||||||
if (!rds->vb)
|
if (!rds->vb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memset(rds->vb, 0, sizeof(struct val_blk));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user