Skip to content

Commit

Permalink
device_mapper: remove dbg_malloc.
Browse files Browse the repository at this point in the history
I wrote dbg_malloc before we had valgrind.  These days there's just
no need.
  • Loading branch information
jthornber committed Jun 8, 2018
1 parent c78239d commit d5da55e
Show file tree
Hide file tree
Showing 80 changed files with 714 additions and 1,118 deletions.
14 changes: 7 additions & 7 deletions daemons/cmirrord/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
block_on_error = 1;
}

lc = dm_zalloc(sizeof(*lc));
lc = zalloc(sizeof(*lc));
if (!lc) {
LOG_ERROR("Unable to allocate cluster log context");
r = -ENOMEM;
Expand Down Expand Up @@ -532,9 +532,9 @@ static int _clog_ctr(char *uuid, uint64_t luid,
LOG_ERROR("Close device error, %s: %s",
disk_path, strerror(errno));
free(lc->disk_buffer);
dm_free(lc->sync_bits);
dm_free(lc->clean_bits);
dm_free(lc);
free(lc->sync_bits);
free(lc->clean_bits);
free(lc);
}
return r;
}
Expand Down Expand Up @@ -659,9 +659,9 @@ static int clog_dtr(struct dm_ulog_request *rq)
strerror(errno));
if (lc->disk_buffer)
free(lc->disk_buffer);
dm_free(lc->clean_bits);
dm_free(lc->sync_bits);
dm_free(lc);
free(lc->clean_bits);
free(lc->sync_bits);
free(lc);

return 0;
}
Expand Down
72 changes: 36 additions & 36 deletions daemons/dmeventd/dmeventd.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,19 @@ static pthread_cond_t _timeout_cond = PTHREAD_COND_INITIALIZER;
/* DSO data allocate/free. */
static void _free_dso_data(struct dso_data *data)
{
dm_free(data->dso_name);
dm_free(data);
free(data->dso_name);
free(data);
}

static struct dso_data *_alloc_dso_data(struct message_data *data)
{
struct dso_data *ret = (typeof(ret)) dm_zalloc(sizeof(*ret));
struct dso_data *ret = (typeof(ret)) zalloc(sizeof(*ret));

if (!ret)
return_NULL;

if (!(ret->dso_name = dm_strdup(data->dso_name))) {
dm_free(ret);
if (!(ret->dso_name = strdup(data->dso_name))) {
free(ret);
return_NULL;
}

Expand Down Expand Up @@ -397,9 +397,9 @@ static void _free_thread_status(struct thread_status *thread)
_lib_put(thread->dso_data);
if (thread->wait_task)
dm_task_destroy(thread->wait_task);
dm_free(thread->device.uuid);
dm_free(thread->device.name);
dm_free(thread);
free(thread->device.uuid);
free(thread->device.name);
free(thread);
}

/* Note: events_field must not be 0, ensured by caller */
Expand All @@ -408,7 +408,7 @@ static struct thread_status *_alloc_thread_status(const struct message_data *dat
{
struct thread_status *thread;

if (!(thread = dm_zalloc(sizeof(*thread)))) {
if (!(thread = zalloc(sizeof(*thread)))) {
log_error("Cannot create new thread, out of memory.");
return NULL;
}
Expand All @@ -422,11 +422,11 @@ static struct thread_status *_alloc_thread_status(const struct message_data *dat
if (!dm_task_set_uuid(thread->wait_task, data->device_uuid))
goto_out;

if (!(thread->device.uuid = dm_strdup(data->device_uuid)))
if (!(thread->device.uuid = strdup(data->device_uuid)))
goto_out;

/* Until real name resolved, use UUID */
if (!(thread->device.name = dm_strdup(data->device_uuid)))
if (!(thread->device.name = strdup(data->device_uuid)))
goto_out;

/* runs ioctl and may register lvm2 pluging */
Expand Down Expand Up @@ -515,7 +515,7 @@ static int _fetch_string(char **ptr, char **src, const int delimiter)
if ((p = strchr(*src, delimiter))) {
if (*src < p) {
*p = 0; /* Temporary exit with \0 */
if (!(*ptr = dm_strdup(*src))) {
if (!(*ptr = strdup(*src))) {
log_error("Failed to fetch item %s.", *src);
ret = 0; /* Allocation fail */
}
Expand All @@ -525,7 +525,7 @@ static int _fetch_string(char **ptr, char **src, const int delimiter)
(*src)++; /* Skip delmiter, next field */
} else if ((len = strlen(*src))) {
/* No delimiter, item ends with '\0' */
if (!(*ptr = dm_strdup(*src))) {
if (!(*ptr = strdup(*src))) {
log_error("Failed to fetch last item %s.", *src);
ret = 0; /* Fail */
}
Expand All @@ -538,11 +538,11 @@ static int _fetch_string(char **ptr, char **src, const int delimiter)
/* Free message memory. */
static void _free_message(struct message_data *message_data)
{
dm_free(message_data->id);
dm_free(message_data->dso_name);
dm_free(message_data->device_uuid);
dm_free(message_data->events_str);
dm_free(message_data->timeout_str);
free(message_data->id);
free(message_data->dso_name);
free(message_data->device_uuid);
free(message_data->events_str);
free(message_data->timeout_str);
}

/* Parse a register message from the client. */
Expand Down Expand Up @@ -574,7 +574,7 @@ static int _parse_message(struct message_data *message_data)
ret = 1;
}

dm_free(msg->data);
free(msg->data);
msg->data = NULL;

return ret;
Expand Down Expand Up @@ -608,8 +608,8 @@ static int _fill_device_data(struct thread_status *ts)
if (!dm_task_run(dmt))
goto fail;

dm_free(ts->device.name);
if (!(ts->device.name = dm_strdup(dm_task_get_name(dmt))))
free(ts->device.name);
if (!(ts->device.name = strdup(dm_task_get_name(dmt))))
goto fail;

if (!dm_task_get_info(dmt, &dmi))
Expand Down Expand Up @@ -696,8 +696,8 @@ static int _get_status(struct message_data *message_data)

len = strlen(message_data->id);
msg->size = size + len + 1;
dm_free(msg->data);
if (!(msg->data = dm_malloc(msg->size)))
free(msg->data);
if (!(msg->data = malloc(msg->size)))
goto out;

memcpy(msg->data, message_data->id, len);
Expand All @@ -712,7 +712,7 @@ static int _get_status(struct message_data *message_data)
ret = 0;
out:
for (j = 0; j < i; ++j)
dm_free(buffers[j]);
free(buffers[j]);

return ret;
}
Expand All @@ -721,7 +721,7 @@ static int _get_parameters(struct message_data *message_data) {
struct dm_event_daemon_message *msg = message_data->msg;
int size;

dm_free(msg->data);
free(msg->data);
if ((size = dm_asprintf(&msg->data, "%s pid=%d daemon=%s exec_method=%s",
message_data->id, getpid(),
_foreground ? "no" : "yes",
Expand Down Expand Up @@ -1225,7 +1225,7 @@ static int _registered_device(struct message_data *message_data,
int r;
struct dm_event_daemon_message *msg = message_data->msg;

dm_free(msg->data);
free(msg->data);

if ((r = dm_asprintf(&(msg->data), "%s %s %s %u",
message_data->id,
Expand Down Expand Up @@ -1365,7 +1365,7 @@ static int _get_timeout(struct message_data *message_data)
if (!thread)
return -ENODEV;

dm_free(msg->data);
free(msg->data);
msg->size = dm_asprintf(&(msg->data), "%s %" PRIu32,
message_data->id, thread->timeout);

Expand Down Expand Up @@ -1502,15 +1502,15 @@ static int _client_read(struct dm_event_fifos *fifos,
bytes = 0;
if (!size)
break; /* No data -> error */
buf = msg->data = dm_malloc(msg->size);
buf = msg->data = malloc(msg->size);
if (!buf)
break; /* No mem -> error */
header = 0;
}
}

if (bytes != size) {
dm_free(msg->data);
free(msg->data);
msg->data = NULL;
return 0;
}
Expand All @@ -1530,7 +1530,7 @@ static int _client_write(struct dm_event_fifos *fifos,
fd_set fds;

size_t size = 2 * sizeof(uint32_t) + ((msg->data) ? msg->size : 0);
uint32_t *header = dm_malloc(size);
uint32_t *header = malloc(size);
char *buf = (char *)header;

if (!header) {
Expand Down Expand Up @@ -1560,7 +1560,7 @@ static int _client_write(struct dm_event_fifos *fifos,
}

if (header != temp)
dm_free(header);
free(header);

return (bytes == size);
}
Expand Down Expand Up @@ -1622,7 +1622,7 @@ static int _do_process_request(struct dm_event_daemon_message *msg)
msg->size = dm_asprintf(&(msg->data), "%s %s %d", answer,
(msg->cmd == DM_EVENT_CMD_DIE) ? "DYING" : "HELLO",
DM_EVENT_PROTOCOL_VERSION);
dm_free(answer);
free(answer);
}
} else if (msg->cmd != DM_EVENT_CMD_ACTIVE && !_parse_message(&message_data)) {
stack;
Expand Down Expand Up @@ -1664,7 +1664,7 @@ static void _process_request(struct dm_event_fifos *fifos)

DEBUGLOG("<<< CMD:%s (0x%x) completed (result %d).", decode_cmd(cmd), cmd, msg.cmd);

dm_free(msg.data);
free(msg.data);

if (cmd == DM_EVENT_CMD_DIE) {
if (unlink(DMEVENTD_PIDFILE))
Expand Down Expand Up @@ -1975,7 +1975,7 @@ static int _reinstate_registrations(struct dm_event_fifos *fifos)
int i, ret;

ret = daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0);
dm_free(msg.data);
free(msg.data);
msg.data = NULL;

if (ret) {
Expand Down Expand Up @@ -2061,13 +2061,13 @@ static void _restart_dmeventd(void)
++count;
}

if (!(_initial_registrations = dm_malloc(sizeof(char*) * (count + 1)))) {
if (!(_initial_registrations = malloc(sizeof(char*) * (count + 1)))) {
fprintf(stderr, "Memory allocation registration failed.\n");
goto bad;
}

for (i = 0; i < count; ++i) {
if (!(_initial_registrations[i] = dm_strdup(message))) {
if (!(_initial_registrations[i] = strdup(message))) {
fprintf(stderr, "Memory allocation for message failed.\n");
goto bad;
}
Expand Down
Loading

0 comments on commit d5da55e

Please sign in to comment.