1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Remove superfluous NULL pointer tests before dm_free from dmeventd.

This commit is contained in:
Alasdair Kergon 2010-08-16 18:19:46 +00:00
parent 51e294c501
commit 59585550a7
4 changed files with 28 additions and 54 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.54 -
================================
Remove superfluous NULL pointer tests before dm_free from dmeventd.
Assume dm-mod autoloading support is in kernel 2.6.36 and higher, not 2.6.35.
Fix udev rules to support udev database content generated by older rules.
Reinstate detection of inappropriate uevent with DISK_RO set and suppress it.

View File

@ -327,12 +327,9 @@ static int _fetch_string(char **ptr, char **src, const int delimiter)
/* Free message memory. */
static void _free_message(struct message_data *message_data)
{
if (message_data->id)
dm_free(message_data->id);
if (message_data->dso_name)
dm_free(message_data->dso_name);
if (message_data->device_uuid)
dm_free(message_data->device_uuid);
}
@ -1051,7 +1048,6 @@ static int _registered_device(struct message_data *message_data,
&& (thread->events)) ? thread->events : thread->
events | DM_EVENT_REGISTRATION_PENDING;
if (msg->data)
dm_free(msg->data);
msg->size = dm_asprintf(&(msg->data), fmt, id, dso, dev, events);
@ -1162,7 +1158,6 @@ static int _get_timeout(struct message_data *message_data)
struct thread_status *thread;
struct dm_event_daemon_message *msg = message_data->msg;
if (msg->data)
dm_free(msg->data);
_lock_mutex();
@ -1287,7 +1282,6 @@ static int _client_read(struct dm_event_fifos *fifos,
}
if (bytes != size) {
if (msg->data)
dm_free(msg->data);
msg->data = NULL;
msg->size = 0;
@ -1416,7 +1410,6 @@ static void _process_request(struct dm_event_fifos *fifos)
if (!_client_write(fifos, &msg))
stack;
if (msg.data)
dm_free(msg.data);
}

View File

@ -47,9 +47,7 @@ struct dm_event_handler {
static void _dm_event_handler_clear_dev_info(struct dm_event_handler *dmevh)
{
if (dmevh->dev_name)
dm_free(dmevh->dev_name);
if (dmevh->uuid)
dm_free(dmevh->uuid);
dmevh->dev_name = dmevh->uuid = NULL;
dmevh->major = dmevh->minor = 0;
@ -73,7 +71,6 @@ struct dm_event_handler *dm_event_handler_create(void)
void dm_event_handler_destroy(struct dm_event_handler *dmevh)
{
_dm_event_handler_clear_dev_info(dmevh);
if (dmevh->dso)
dm_free(dmevh->dso);
dm_free(dmevh);
}
@ -82,7 +79,6 @@ int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path)
{
if (!path) /* noop */
return 0;
if (dmevh->dso)
dm_free(dmevh->dso);
dmevh->dso = dm_strdup(path);
@ -259,7 +255,6 @@ static int _daemon_read(struct dm_event_fifos *fifos,
}
if (bytes != size) {
if (msg->data)
dm_free(msg->data);
msg->data = NULL;
}
@ -366,7 +361,6 @@ static int _daemon_talk(struct dm_event_fifos *fifos,
do {
if (msg->data)
dm_free(msg->data);
msg->data = 0;
@ -564,7 +558,6 @@ static int _do_event(int cmd, struct dm_event_daemon_message *msg,
ret = _daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, 0, 0, 0, 0);
if (msg->data)
dm_free(msg->data);
msg->data = 0;
@ -600,7 +593,6 @@ int dm_event_register_handler(const struct dm_event_handler *dmevh)
ret = 0;
}
if (msg.data)
dm_free(msg.data);
dm_task_destroy(dmt);
@ -630,7 +622,6 @@ int dm_event_unregister_handler(const struct dm_event_handler *dmevh)
ret = 0;
}
if (msg.data)
dm_free(msg.data);
dm_task_destroy(dmt);
@ -711,10 +702,8 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
dm_task_destroy(dmt);
dmt = NULL;
if (msg.data) {
dm_free(msg.data);
msg.data = NULL;
}
_dm_event_handler_clear_dev_info(dmevh);
dmevh->uuid = dm_strdup(reply_uuid);
@ -731,15 +720,11 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
dm_event_handler_set_dso(dmevh, reply_dso);
dm_event_handler_set_event_mask(dmevh, reply_mask);
if (reply_dso) {
dm_free(reply_dso);
reply_dso = NULL;
}
if (reply_uuid) {
dm_free(reply_uuid);
reply_uuid = NULL;
}
dmevh->dev_name = dm_strdup(dm_task_get_name(dmt));
if (!dmevh->dev_name) {
@ -760,11 +745,8 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
return ret;
fail:
if (msg.data)
dm_free(msg.data);
if (reply_dso)
dm_free(reply_dso);
if (reply_uuid)
dm_free(reply_uuid);
_dm_event_handler_clear_dev_info(dmevh);
if (dmt)

View File

@ -119,12 +119,10 @@ static int _get_mirror_event(char *params)
goto out_parse;
out:
if (args)
dm_free(args);
return r;
out_parse:
if (args)
dm_free(args);
syslog(LOG_ERR, "Unable to parse mirror status string.");
return ME_IGNORE;