1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cleanup: use dm_free without extra test

It's ok to free(NULL).
This commit is contained in:
Zdenek Kabelac 2014-03-24 09:20:18 +01:00
parent 4a6f05e420
commit 406ec4162f
4 changed files with 12 additions and 18 deletions

View File

@ -700,8 +700,7 @@ static int _parse_message(struct dm_event_daemon_message *msg, char **dso_name,
return 0;
}
if (id)
dm_free(id);
dm_free(id);
return -ENOMEM;
}
@ -863,12 +862,13 @@ int dm_event_get_timeout(const char *device_path, uint32_t *timeout)
if (!p) {
log_error("malformed reply from dmeventd '%s'\n",
msg.data);
dm_free(msg.data);
return -EIO;
}
*timeout = atoi(p);
}
if (msg.data)
dm_free(msg.data);
dm_free(msg.data);
return ret;
}
#endif

3
lib/cache/lvmetad.c vendored
View File

@ -114,8 +114,7 @@ void lvmetad_set_token(const struct dm_config_value *filter)
{
int ft = 0;
if (_lvmetad_token)
dm_free(_lvmetad_token);
dm_free(_lvmetad_token);
while (filter && filter->type == DM_CFG_STRING) {
ft = calc_crc(ft, (const uint8_t *) filter->v.str, strlen(filter->v.str));

View File

@ -677,10 +677,8 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!dev_close(mdac->area.dev))
stack;
if (fidtc->raw_metadata_buf) {
dm_free(fidtc->raw_metadata_buf);
fidtc->raw_metadata_buf = NULL;
}
dm_free(fidtc->raw_metadata_buf);
fidtc->raw_metadata_buf = NULL;
}
return r;
@ -766,10 +764,9 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
if (!precommit) {
if (!dev_close(mdac->area.dev))
stack;
if (fidtc->raw_metadata_buf) {
dm_free(fidtc->raw_metadata_buf);
fidtc->raw_metadata_buf = NULL;
}
dm_free(fidtc->raw_metadata_buf);
fidtc->raw_metadata_buf = NULL;
}
return r;

View File

@ -169,15 +169,13 @@ static int _clear_dev_from_lvmetad_cache(dev_t devno, int32_t major, int32_t min
if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
stack;
if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
if (buf)
dm_free(buf);
dm_free(buf);
return 0;
}
log_print_unless_silent("Device %s not found. "
"Cleared from lvmetad cache.", buf ? : "");
if (buf)
dm_free(buf);
dm_free(buf);
return 1;
}