mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: free already does NULL check
Drop extra check for NULL before calling free(). Also drop zeroing data that will be free().
This commit is contained in:
parent
73087c2c0f
commit
ed59b50512
@ -438,18 +438,11 @@ static void free_pvs_path(struct pvs *pvs)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < pvs->num; i++) {
|
for (i = 0; i < pvs->num; i++)
|
||||||
if (!pvs->path[i])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
free((char *)pvs->path[i]);
|
free((char *)pvs->path[i]);
|
||||||
pvs->path[i] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pvs->path) {
|
free(pvs->path);
|
||||||
free(pvs->path);
|
pvs->path = NULL;
|
||||||
pvs->path = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **alloc_and_copy_pvs_path(struct pvs *dst, struct pvs *src)
|
static char **alloc_and_copy_pvs_path(struct pvs *dst, struct pvs *src)
|
||||||
@ -563,10 +556,8 @@ static struct lock *alloc_lock(void)
|
|||||||
|
|
||||||
static void free_action(struct action *act)
|
static void free_action(struct action *act)
|
||||||
{
|
{
|
||||||
if (act->path) {
|
free(act->path);
|
||||||
free(act->path);
|
act->path = NULL;
|
||||||
act->path = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free_pvs_path(&act->pvs);
|
free_pvs_path(&act->pvs);
|
||||||
|
|
||||||
|
@ -456,8 +456,9 @@ int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
|
|||||||
fail:
|
fail:
|
||||||
if (lmi && lmi->sock)
|
if (lmi && lmi->sock)
|
||||||
close(lmi->sock);
|
close(lmi->sock);
|
||||||
if (lmi)
|
|
||||||
free(lmi);
|
free(lmi);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,8 +507,7 @@ int lm_rem_resource_idm(struct lockspace *ls, struct resource *r)
|
|||||||
{
|
{
|
||||||
struct rd_idm *rdi = (struct rd_idm *)r->lm_data;
|
struct rd_idm *rdi = (struct rd_idm *)r->lm_data;
|
||||||
|
|
||||||
if (rdi->vb)
|
free(rdi->vb);
|
||||||
free(rdi->vb);
|
|
||||||
|
|
||||||
memset(rdi, 0, sizeof(struct rd_idm));
|
memset(rdi, 0, sizeof(struct rd_idm));
|
||||||
r->lm_init = 0;
|
r->lm_init = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user