diff options
author | Joe Thornber <ejt@redhat.com> | 2018-06-08 13:40:53 +0100 |
---|---|---|
committer | Joe Thornber <ejt@redhat.com> | 2018-06-08 13:40:53 +0100 |
commit | d5da55ed85248adb066d293c2a1b863ce17d2779 (patch) | |
tree | e526dd2f773e3016a3acd3cb8e490ed11ba7c439 /daemons | |
parent | c78239d8605f333915543c0e0c3ccf4f4ef5ee8f (diff) | |
download | lvm2-d5da55ed85248adb066d293c2a1b863ce17d2779.tar.gz |
device_mapper: remove dbg_malloc.
I wrote dbg_malloc before we had valgrind. These days there's just
no need.
Diffstat (limited to 'daemons')
-rw-r--r-- | daemons/cmirrord/functions.c | 14 | ||||
-rw-r--r-- | daemons/dmeventd/dmeventd.c | 72 | ||||
-rw-r--r-- | daemons/dmeventd/libdevmapper-event.c | 64 | ||||
-rw-r--r-- | daemons/dmfilemapd/dmfilemapd.c | 14 | ||||
-rw-r--r-- | daemons/lvmetad/lvmetad-core.c | 78 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-cmd-utils.c | 10 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-core.c | 16 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-data-utils.c | 54 |
8 files changed, 161 insertions, 161 deletions
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c index 5e43e1a3b..61bcf16df 100644 --- a/daemons/cmirrord/functions.c +++ b/daemons/cmirrord/functions.c @@ -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; @@ -532,9 +532,9 @@ fail: 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; } @@ -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; } diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 533186b97..4b4e1f0fd 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -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; } @@ -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 */ @@ -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; } @@ -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 */ @@ -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 */ } @@ -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 */ } @@ -538,11 +538,11 @@ out: /* 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. */ @@ -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; @@ -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)) @@ -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); @@ -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; } @@ -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", @@ -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, @@ -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); @@ -1502,7 +1502,7 @@ 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; @@ -1510,7 +1510,7 @@ static int _client_read(struct dm_event_fifos *fifos, } if (bytes != size) { - dm_free(msg->data); + free(msg->data); msg->data = NULL; return 0; } @@ -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) { @@ -1560,7 +1560,7 @@ static int _client_write(struct dm_event_fifos *fifos, } if (header != temp) - dm_free(header); + free(header); return (bytes == size); } @@ -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; @@ -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)) @@ -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) { @@ -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; } diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c index 7f0722831..4673f015a 100644 --- a/daemons/dmeventd/libdevmapper-event.c +++ b/daemons/dmeventd/libdevmapper-event.c @@ -49,8 +49,8 @@ struct dm_event_handler { static void _dm_event_handler_clear_dev_info(struct dm_event_handler *dmevh) { - dm_free(dmevh->dev_name); - dm_free(dmevh->uuid); + free(dmevh->dev_name); + free(dmevh->uuid); dmevh->dev_name = dmevh->uuid = NULL; dmevh->major = dmevh->minor = 0; } @@ -59,7 +59,7 @@ struct dm_event_handler *dm_event_handler_create(void) { struct dm_event_handler *dmevh; - if (!(dmevh = dm_zalloc(sizeof(*dmevh)))) { + if (!(dmevh = zalloc(sizeof(*dmevh)))) { log_error("Failed to allocate event handler."); return NULL; } @@ -70,9 +70,9 @@ 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); - dm_free(dmevh->dso); - dm_free(dmevh->dmeventd_path); - dm_free(dmevh); + free(dmevh->dso); + free(dmevh->dmeventd_path); + free(dmevh); } int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const char *dmeventd_path) @@ -80,9 +80,9 @@ int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const cha if (!dmeventd_path) /* noop */ return 0; - dm_free(dmevh->dmeventd_path); + free(dmevh->dmeventd_path); - if (!(dmevh->dmeventd_path = dm_strdup(dmeventd_path))) + if (!(dmevh->dmeventd_path = strdup(dmeventd_path))) return -ENOMEM; return 0; @@ -93,9 +93,9 @@ int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path) if (!path) /* noop */ return 0; - dm_free(dmevh->dso); + free(dmevh->dso); - if (!(dmevh->dso = dm_strdup(path))) + if (!(dmevh->dso = strdup(path))) return -ENOMEM; return 0; @@ -108,7 +108,7 @@ int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *de _dm_event_handler_clear_dev_info(dmevh); - if (!(dmevh->dev_name = dm_strdup(dev_name))) + if (!(dmevh->dev_name = strdup(dev_name))) return -ENOMEM; return 0; @@ -121,7 +121,7 @@ int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid) _dm_event_handler_clear_dev_info(dmevh); - if (!(dmevh->uuid = dm_strdup(uuid))) + if (!(dmevh->uuid = strdup(uuid))) return -ENOMEM; return 0; @@ -261,7 +261,7 @@ static int _daemon_read(struct dm_event_fifos *fifos, if (header && (bytes == 2 * sizeof(uint32_t))) { msg->cmd = ntohl(header[0]); msg->size = ntohl(header[1]); - buf = msg->data = dm_malloc(msg->size); + buf = msg->data = malloc(msg->size); size = msg->size; bytes = 0; header = 0; @@ -269,7 +269,7 @@ static int _daemon_read(struct dm_event_fifos *fifos, } if (bytes != size) { - dm_free(msg->data); + free(msg->data); msg->data = NULL; } return bytes == size; @@ -372,13 +372,13 @@ int daemon_talk(struct dm_event_fifos *fifos, */ if (!_daemon_write(fifos, msg)) { stack; - dm_free(msg->data); + free(msg->data); msg->data = NULL; return -EIO; } do { - dm_free(msg->data); + free(msg->data); msg->data = NULL; if (!_daemon_read(fifos, msg)) { @@ -621,7 +621,7 @@ static int _do_event(int cmd, char *dmeventd_path, struct dm_event_daemon_messag ret = daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0); - dm_free(msg->data); + free(msg->data); msg->data = 0; if (!ret) @@ -661,7 +661,7 @@ int dm_event_register_handler(const struct dm_event_handler *dmevh) ret = 0; } - dm_free(msg.data); + free(msg.data); dm_task_destroy(dmt); @@ -688,7 +688,7 @@ int dm_event_unregister_handler(const struct dm_event_handler *dmevh) ret = 0; } - dm_free(msg.data); + free(msg.data); dm_task_destroy(dmt); @@ -704,7 +704,7 @@ static char *_fetch_string(char **src, const int delimiter) if ((p = strchr(*src, delimiter))) *p = 0; - if ((ret = dm_strdup(*src))) + if ((ret = strdup(*src))) *src += strlen(ret) + 1; if (p) @@ -724,11 +724,11 @@ static int _parse_message(struct dm_event_daemon_message *msg, char **dso_name, (*dso_name = _fetch_string(&p, ' ')) && (*uuid = _fetch_string(&p, ' '))) { *evmask = atoi(p); - dm_free(id); + free(id); return 0; } - dm_free(id); + free(id); return -ENOMEM; } @@ -770,7 +770,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next) dm_task_destroy(dmt); dmt = NULL; - dm_free(msg.data); + free(msg.data); msg.data = NULL; _dm_event_handler_clear_dev_info(dmevh); @@ -779,7 +779,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next) goto fail; } - if (!(dmevh->uuid = dm_strdup(reply_uuid))) { + if (!(dmevh->uuid = strdup(reply_uuid))) { ret = -ENOMEM; goto fail; } @@ -792,13 +792,13 @@ 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); - dm_free(reply_dso); + free(reply_dso); reply_dso = NULL; - dm_free(reply_uuid); + free(reply_uuid); reply_uuid = NULL; - if (!(dmevh->dev_name = dm_strdup(dm_task_get_name(dmt)))) { + if (!(dmevh->dev_name = strdup(dm_task_get_name(dmt)))) { ret = -ENOMEM; goto fail; } @@ -816,9 +816,9 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next) return ret; fail: - dm_free(msg.data); - dm_free(reply_dso); - dm_free(reply_uuid); + free(msg.data); + free(reply_dso); + free(reply_uuid); _dm_event_handler_clear_dev_info(dmevh); if (dmt) dm_task_destroy(dmt); @@ -983,12 +983,12 @@ int dm_event_get_timeout(const char *device_path, uint32_t *timeout) if (!p) { log_error("Malformed reply from dmeventd '%s'.", msg.data); - dm_free(msg.data); + free(msg.data); return -EIO; } *timeout = atoi(p); } - dm_free(msg.data); + free(msg.data); return ret; } diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c index 4e048fff3..726ad6ec2 100644 --- a/daemons/dmfilemapd/dmfilemapd.c +++ b/daemons/dmfilemapd/dmfilemapd.c @@ -311,7 +311,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm) return 0; } - fm->path = dm_strdup(argv[0]); + fm->path = strdup(argv[0]); if (!fm->path) { _early_log("Could not allocate memory for path argument."); return 0; @@ -538,8 +538,8 @@ static void _filemap_monitor_destroy(struct filemap_monitor *fm) _filemap_monitor_end_notify(fm); _filemap_monitor_close_fd(fm); } - dm_free((void *) fm->program_id); - dm_free(fm->path); + free((void *) fm->program_id); + free(fm->path); } static int _filemap_monitor_check_same_file(int fd1, int fd2) @@ -699,7 +699,7 @@ static int _update_regions(struct dm_stats *dms, struct filemap_monitor *fm) fm->group_id, regions[0]); fm->group_id = regions[0]; } - dm_free(regions); + free(regions); fm->nr_regions = nr_regions; return 1; } @@ -741,7 +741,7 @@ static int _dmfilemapd(struct filemap_monitor *fm) */ program_id = dm_stats_get_region_program_id(dms, fm->group_id); if (program_id) - fm->program_id = dm_strdup(program_id); + fm->program_id = strdup(program_id); else fm->program_id = NULL; dm_stats_set_program_id(dms, 1, program_id); @@ -817,7 +817,7 @@ int main(int argc, char **argv) memset(&fm, 0, sizeof(fm)); if (!_parse_args(argc, argv, &fm)) { - dm_free(fm.path); + free(fm.path); return 1; } @@ -828,7 +828,7 @@ int main(int argc, char **argv) _mode_names[fm.mode], fm.path); if (!_foreground && !_daemonise(&fm)) { - dm_free(fm.path); + free(fm.path); return 1; } diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 8858e29b1..cd44be570 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -259,19 +259,19 @@ static void destroy_metadata_hashes(lvmetad_state *s) dm_config_destroy(dm_hash_get_data(s->pvid_to_pvmeta, n)); dm_hash_iterate(n, s->vgid_to_vgname) - dm_free(dm_hash_get_data(s->vgid_to_vgname, n)); + free(dm_hash_get_data(s->vgid_to_vgname, n)); dm_hash_iterate(n, s->vgname_to_vgid) - dm_free(dm_hash_get_data(s->vgname_to_vgid, n)); + free(dm_hash_get_data(s->vgname_to_vgid, n)); dm_hash_iterate(n, s->vgid_to_info) - dm_free(dm_hash_get_data(s->vgid_to_info, n)); + free(dm_hash_get_data(s->vgid_to_info, n)); dm_hash_iterate(n, s->device_to_pvid) - dm_free(dm_hash_get_data(s->device_to_pvid, n)); + free(dm_hash_get_data(s->device_to_pvid, n)); dm_hash_iterate(n, s->pvid_to_vgid) - dm_free(dm_hash_get_data(s->pvid_to_vgid, n)); + free(dm_hash_get_data(s->pvid_to_vgid, n)); dm_hash_destroy(s->pvid_to_pvmeta); dm_hash_destroy(s->vgid_to_metadata); @@ -818,19 +818,19 @@ static int _update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg, if (mode == MARK_OUTDATED) mark_outdated_pv(s, vgid, pvid); - if (!(vgid_dup = dm_strdup(vgid))) { + if (!(vgid_dup = strdup(vgid))) { ERROR(s, "update_pvid_to_vgid out of memory for vgid %s", vgid); goto abort_daemon; } if (!dm_hash_insert(s->pvid_to_vgid, pvid, vgid_dup)) { ERROR(s, "update_pvid_to_vgid out of memory for hash insert vgid %s", vgid_dup); - dm_free(vgid_dup); + free(vgid_dup); goto abort_daemon; } /* pvid_to_vgid no longer references vgid_old */ - dm_free(vgid_old); + free(vgid_old); DEBUGLOG(s, "moving PV %s to VG %s", pvid, vgid); } @@ -889,9 +889,9 @@ static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids) dm_config_destroy(meta_lookup); if (outdated_pvs_lookup) dm_config_destroy(outdated_pvs_lookup); - dm_free(info_lookup); - dm_free(name_lookup); - dm_free(vgid_lookup); + free(info_lookup); + free(name_lookup); + free(vgid_lookup); return 1; } @@ -950,7 +950,7 @@ static void _purge_metadata(lvmetad_state *s, const char *arg_name, const char * if ((rem_vgid = dm_hash_lookup_with_val(s->vgname_to_vgid, arg_name, arg_vgid, strlen(arg_vgid) + 1))) { dm_hash_remove_with_val(s->vgname_to_vgid, arg_name, arg_vgid, strlen(arg_vgid) + 1); - dm_free(rem_vgid); + free(rem_vgid); } } @@ -978,10 +978,10 @@ static int _update_metadata_new_vgid(lvmetad_state *s, int abort_daemon = 0; int retval = 0; - if (!(new_vgid_dup = dm_strdup(new_vgid))) + if (!(new_vgid_dup = strdup(new_vgid))) goto ret; - if (!(arg_name_dup = dm_strdup(arg_name))) + if (!(arg_name_dup = strdup(arg_name))) goto ret; /* @@ -999,7 +999,7 @@ static int _update_metadata_new_vgid(lvmetad_state *s, if ((rem_info = dm_hash_lookup(s->vgid_to_info, old_vgid))) { dm_hash_remove(s->vgid_to_info, old_vgid); - dm_free(rem_info); + free(rem_info); } if ((rem_outdated = dm_hash_lookup(s->vgid_to_outdated_pvs, old_vgid))) { @@ -1013,7 +1013,7 @@ static int _update_metadata_new_vgid(lvmetad_state *s, dm_hash_remove_with_val(s->vgname_to_vgid, arg_name, old_vgid, strlen(old_vgid) + 1); dm_hash_remove(s->vgid_to_vgname, old_vgid); - dm_free((char *)old_vgid); + free((char *)old_vgid); old_vgid = NULL; /* @@ -1085,10 +1085,10 @@ static int _update_metadata_new_name(lvmetad_state *s, int abort_daemon = 0; int retval = 0; - if (!(new_name_dup = dm_strdup(new_name))) + if (!(new_name_dup = strdup(new_name))) goto ret; - if (!(arg_vgid_dup = dm_strdup(arg_vgid))) + if (!(arg_vgid_dup = strdup(arg_vgid))) goto ret; /* @@ -1106,7 +1106,7 @@ static int _update_metadata_new_name(lvmetad_state *s, if ((rem_info = dm_hash_lookup(s->vgid_to_info, arg_vgid))) { dm_hash_remove(s->vgid_to_info, arg_vgid); - dm_free(rem_info); + free(rem_info); } if ((rem_outdated = dm_hash_lookup(s->vgid_to_outdated_pvs, arg_vgid))) { @@ -1120,7 +1120,7 @@ static int _update_metadata_new_name(lvmetad_state *s, dm_hash_remove(s->vgid_to_vgname, arg_vgid); dm_hash_remove_with_val(s->vgname_to_vgid, old_name, arg_vgid, strlen(arg_vgid) + 1); - dm_free((char *)old_name); + free((char *)old_name); old_name = NULL; /* @@ -1183,10 +1183,10 @@ static int _update_metadata_add_new(lvmetad_state *s, const char *new_name, cons DEBUGLOG(s, "update_metadata_add_new for %s %s", new_name, new_vgid); - if (!(new_name_dup = dm_strdup(new_name))) + if (!(new_name_dup = strdup(new_name))) goto out_free; - if (!(new_vgid_dup = dm_strdup(new_vgid))) + if (!(new_vgid_dup = strdup(new_vgid))) goto out_free; if (!dm_hash_insert(s->vgid_to_metadata, new_vgid, new_meta)) { @@ -1218,8 +1218,8 @@ static int _update_metadata_add_new(lvmetad_state *s, const char *new_name, cons out: out_free: if (!new_name_dup || !new_vgid_dup || abort_daemon) { - dm_free(new_name_dup); - dm_free(new_vgid_dup); + free(new_name_dup); + free(new_vgid_dup); ERROR(s, "lvmetad could not be updated and is aborting."); exit(EXIT_FAILURE); } @@ -1799,17 +1799,17 @@ static response pv_gone(lvmetad_state *s, request r) * mappings for this vg, which will free the "vgid" string that * was returned above from the pvid_to_vgid lookup. */ - if (!(vgid_dup = dm_strdup(vgid))) + if (!(vgid_dup = strdup(vgid))) return reply_fail("out of memory"); vg_remove_if_missing(s, vgid_dup, 1); - dm_free(vgid_dup); + free(vgid_dup); vgid_dup = NULL; vgid = NULL; } dm_config_destroy(pvmeta); - dm_free(old_pvid); + free(old_pvid); return daemon_reply_simple("OK", NULL ); } @@ -2082,7 +2082,7 @@ static response pv_found(lvmetad_state *s, request r) DEBUGLOG(s, "pv_found new entry device_to_pvid %" PRIu64 " to %s", new_device, new_pvid); - if (!(new_pvid_dup = dm_strdup(new_pvid))) + if (!(new_pvid_dup = strdup(new_pvid))) goto nomem_free1; if (!dm_hash_insert_binary(s->device_to_pvid, &new_device, sizeof(new_device), new_pvid_dup)) @@ -2122,7 +2122,7 @@ static response pv_found(lvmetad_state *s, request r) arg_device, arg_pvid); dm_config_destroy(new_pvmeta); /* device_to_pvid no longer references prev_pvid_lookup */ - dm_free((void*)prev_pvid_on_dev); + free((void*)prev_pvid_on_dev); s->flags |= GLFL_DISABLE; s->flags |= GLFL_DISABLE_REASON_DUPLICATES; return reply_fail("Ignore duplicate PV"); @@ -2130,7 +2130,7 @@ static response pv_found(lvmetad_state *s, request r) } - if (!(new_pvid_dup = dm_strdup(new_pvid))) + if (!(new_pvid_dup = strdup(new_pvid))) goto nomem_free1; if (!dm_hash_insert_binary(s->device_to_pvid, &arg_device, sizeof(arg_device), new_pvid_dup)) @@ -2218,22 +2218,22 @@ static response pv_found(lvmetad_state *s, request r) char *tmp_vgid; if (!arg_vgid || strcmp(arg_vgid, prev_vgid_on_dev)) { - tmp_vgid = dm_strdup(prev_vgid_on_dev); + tmp_vgid = strdup(prev_vgid_on_dev); /* vg_remove_if_missing will clear and free the string pointed to by prev_vgid_on_dev. */ vg_remove_if_missing(s, tmp_vgid, 1); - dm_free(tmp_vgid); + free(tmp_vgid); } /* vg_remove_if_missing may have remapped prev_pvid_on_dev to orphan */ if ((tmp_vgid = dm_hash_lookup(s->pvid_to_vgid, prev_pvid_on_dev))) { dm_hash_remove(s->pvid_to_vgid, prev_pvid_on_dev); - dm_free(tmp_vgid); + free(tmp_vgid); } } /* This was unhashed from device_to_pvid above. */ - dm_free((void *)prev_pvid_on_dev); + free((void *)prev_pvid_on_dev); return daemon_reply_simple("OK", "status = %s", vg_status, @@ -2245,7 +2245,7 @@ static response pv_found(lvmetad_state *s, request r) NULL); nomem_free2: - dm_free(new_pvid_dup); + free(new_pvid_dup); nomem_free1: dm_config_destroy(new_pvmeta); nomem: @@ -2525,7 +2525,7 @@ inval: info = dm_hash_lookup(s->vgid_to_info, uuid); if (!info) { - if (!(info = dm_zalloc(sizeof(struct vg_info)))) + if (!(info = zalloc(sizeof(struct vg_info)))) goto bad; if (!dm_hash_insert(s->vgid_to_info, uuid, (void*)info)) goto bad; @@ -2570,7 +2570,7 @@ static void _dump_pairs(struct buffer *buf, struct dm_hash_table *ht, const char (void) dm_asprintf(&append, " %s = \"%s\"\n", key, val); if (append) buffer_append(buf, append); - dm_free(append); + free(append); } buffer_append(buf, "}\n"); } @@ -2590,7 +2590,7 @@ static void _dump_info_version(struct buffer *buf, struct dm_hash_table *ht, con (void) dm_asprintf(&append, " %s = %lld\n", key, (long long)info->external_version); if (append) buffer_append(buf, append); - dm_free(append); + free(append); n = dm_hash_get_next(ht, n); } buffer_append(buf, "}\n"); @@ -2611,7 +2611,7 @@ static void _dump_info_flags(struct buffer *buf, struct dm_hash_table *ht, const (void) dm_asprintf(&append, " %s = %llx\n", key, (long long)info->flags); if (append) buffer_append(buf, append); - dm_free(append); + free(append); n = dm_hash_get_next(ht, n); } buffer_append(buf, "}\n"); diff --git a/daemons/lvmpolld/lvmpolld-cmd-utils.c b/daemons/lvmpolld/lvmpolld-cmd-utils.c index 601338fff..865b47ec9 100644 --- a/daemons/lvmpolld/lvmpolld-cmd-utils.c +++ b/daemons/lvmpolld/lvmpolld-cmd-utils.c @@ -36,7 +36,7 @@ static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind) const char **newargv; if (*ind && !(*ind % MIN_ARGV_SIZE)) { - newargv = dm_realloc(*cmdargv, (*ind / MIN_ARGV_SIZE + 1) * MIN_ARGV_SIZE * sizeof(char *)); + newargv = realloc(*cmdargv, (*ind / MIN_ARGV_SIZE + 1) * MIN_ARGV_SIZE * sizeof(char *)); if (!newargv) return 0; *cmdargv = newargv; @@ -50,7 +50,7 @@ static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind) const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary, unsigned abort_polling, unsigned handle_missing_pvs) { unsigned i = 0; - const char **cmd_argv = dm_malloc(MIN_ARGV_SIZE * sizeof(char *)); + const char **cmd_argv = malloc(MIN_ARGV_SIZE * sizeof(char *)); if (!cmd_argv) return NULL; @@ -98,7 +98,7 @@ const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary, return cmd_argv; err: - dm_free(cmd_argv); + free(cmd_argv); return NULL; } @@ -122,7 +122,7 @@ static int copy_env(const char ***cmd_envp, unsigned *i, const char *exclude) const char **cmdenvp_ctr(const struct lvmpolld_lv *pdlv) { unsigned i = 0; - const char **cmd_envp = dm_malloc(MIN_ARGV_SIZE * sizeof(char *)); + const char **cmd_envp = malloc(MIN_ARGV_SIZE * sizeof(char *)); if (!cmd_envp) return NULL; @@ -141,6 +141,6 @@ const char **cmdenvp_ctr(const struct lvmpolld_lv *pdlv) return cmd_envp; err: - dm_free(cmd_envp); + free(cmd_envp); return NULL; } diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c index fd7327241..3aac65f23 100644 --- a/daemons/lvmpolld/lvmpolld-core.c +++ b/daemons/lvmpolld/lvmpolld-core.c @@ -530,7 +530,7 @@ static response progress_info(client_handle h, struct lvmpolld_state *ls, reques pdst_unlock(pdst); - dm_free(id); + free(id); if (pdlv) { if (st.error) @@ -673,7 +673,7 @@ static response poll_init(client_handle h, struct lvmpolld_state *ls, request re PD_LOG_PREFIX, "poll operation type mismatch on LV identified by", id, polling_op(pdlv_get_type(pdlv)), polling_op(type)); - dm_free(id); + free(id); return reply(LVMPD_RESP_EINVAL, REASON_DIFFERENT_OPERATION_IN_PROGRESS); } @@ -683,14 +683,14 @@ static response poll_init(client_handle h, struct lvmpolld_state *ls, request re lvname, sysdir, type, abort_polling, 2 * uinterval); if (!pdlv) { pdst_unlock(pdst); - dm_free(id); + free(id); return reply(LVMPD_RESP_FAILED, REASON_ENOMEM); } if (!pdst_locked_insert(pdst, id, pdlv)) { pdlv_destroy(pdlv); pdst_unlock(pdst); ERROR(ls, "%s: %s", PD_LOG_PREFIX, "couldn't store internal LV data structure"); - dm_free(id); + free(id); return reply(LVMPD_RESP_FAILED, REASON_ENOMEM); } if (!spawn_detached_thread(pdlv)) { @@ -698,7 +698,7 @@ static response poll_init(client_handle h, struct lvmpolld_state *ls, request re pdst_locked_remove(pdst, id); pdlv_destroy(pdlv); pdst_unlock(pdst); - dm_free(id); + free(id); return reply(LVMPD_RESP_FAILED, REASON_ENOMEM); } @@ -709,7 +709,7 @@ static response poll_init(client_handle h, struct lvmpolld_state *ls, request re pdst_unlock(pdst); - dm_free(id); + free(id); return daemon_reply_simple(LVMPD_RESP_OK, NULL); } @@ -806,7 +806,7 @@ static int printout_raw_response(const char *prefix, const char *msg) char *buf; char *pos; - buf = dm_strdup(msg); + buf = strdup(msg); pos = buf; if (!buf) @@ -819,7 +819,7 @@ static int printout_raw_response(const char *prefix, const char *msg) _log_line(pos, &b); pos = next ? next + 1 : 0; } - dm_free(buf); + free(buf); return 1; } diff --git a/daemons/lvmpolld/lvmpolld-data-utils.c b/daemons/lvmpolld/lvmpolld-data-utils.c index d5e113936..23e316a96 100644 --- a/daemons/lvmpolld/lvmpolld-data-utils.c +++ b/daemons/lvmpolld/lvmpolld-data-utils.c @@ -27,12 +27,12 @@ static char *_construct_full_lvname(const char *vgname, const char *lvname) size_t l; l = strlen(vgname) + strlen(lvname) + 2; /* vg/lv and \0 */ - name = (char *) dm_malloc(l * sizeof(char)); + name = (char *) malloc(l * sizeof(char)); if (!name) return NULL; if (dm_snprintf(name, l, "%s/%s", vgname, lvname) < 0) { - dm_free(name); + free(name); name = NULL; } @@ -47,7 +47,7 @@ static char *_construct_lvm_system_dir_env(const char *sysdir) * just single char to store NULL byte */ size_t l = sysdir ? strlen(sysdir) + 16 : 1; - char *env = (char *) dm_malloc(l * sizeof(char)); + char *env = (char *) malloc(l * sizeof(char)); if (!env) return NULL; @@ -55,7 +55,7 @@ static char *_construct_lvm_system_dir_env(const char *sysdir) *env = '\0'; if (sysdir && dm_snprintf(env, l, "%s%s", LVM_SYSTEM_DIR, sysdir) < 0) { - dm_free(env); + free(env); env = NULL; } @@ -74,7 +74,7 @@ char *construct_id(const char *sysdir, const char *uuid) size_t l; l = strlen(uuid) + (sysdir ? strlen(sysdir) : 0) + 1; - id = (char *) dm_malloc(l * sizeof(char)); + id = (char *) malloc(l * sizeof(char)); if (!id) return NULL; @@ -82,7 +82,7 @@ char *construct_id(const char *sysdir, const char *uuid) dm_snprintf(id, l, "%s", uuid); if (r < 0) { - dm_free(id); + free(id); id = NULL; } @@ -95,7 +95,7 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, const char *sinterval, unsigned pdtimeout, struct lvmpolld_store *pdst) { - char *lvmpolld_id = dm_strdup(id), /* copy */ + char *lvmpolld_id = strdup(id), /* copy */ *full_lvname = _construct_full_lvname(vgname, lvname), /* copy */ *lvm_system_dir_env = _construct_lvm_system_dir_env(sysdir); /* copy */ @@ -106,12 +106,12 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, .lvid = _get_lvid(lvmpolld_id, sysdir), .lvname = full_lvname, .lvm_system_dir_env = lvm_system_dir_env, - .sinterval = dm_strdup(sinterval), /* copy */ + .sinterval = strdup(sinterval), /* copy */ .pdtimeout = pdtimeout < MIN_POLLING_TIMEOUT ? MIN_POLLING_TIMEOUT : pdtimeout, .cmd_state = { .retcode = -1, .signal = 0 }, .pdst = pdst, .init_rq_count = 1 - }, *pdlv = (struct lvmpolld_lv *) dm_malloc(sizeof(struct lvmpolld_lv)); + }, *pdlv = (struct lvmpolld_lv *) malloc(sizeof(struct lvmpolld_lv)); if (!pdlv || !tmp.lvid || !tmp.lvname || !tmp.lvm_system_dir_env || !tmp.sinterval) goto err; @@ -124,27 +124,27 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, return pdlv; err: - dm_free((void *)full_lvname); - dm_free((void *)lvmpolld_id); - dm_free((void *)lvm_system_dir_env); - dm_free((void *)tmp.sinterval); - dm_free((void *)pdlv); + free((void *)full_lvname); + free((void *)lvmpolld_id); + free((void *)lvm_system_dir_env); + free((void *)tmp.sinterval); + free((void *)pdlv); return NULL; } void pdlv_destroy(struct lvmpolld_lv *pdlv) { - dm_free((void *)pdlv->lvmpolld_id); - dm_free((void *)pdlv->lvname); - dm_free((void *)pdlv->sinterval); - dm_free((void *)pdlv->lvm_system_dir_env); - dm_free((void *)pdlv->cmdargv); - dm_free((void *)pdlv->cmdenvp); + free((void *)pdlv->lvmpolld_id); + free((void *)pdlv->lvname); + free((void *)pdlv->sinterval); + free((void *)pdlv->lvm_system_dir_env); + free((void *)pdlv->cmdargv); + free((void *)pdlv->cmdenvp); pthread_mutex_destroy(&pdlv->lock); - dm_free((void *)pdlv); + free((void *)pdlv); } unsigned pdlv_get_polling_finished(struct lvmpolld_lv *pdlv) @@ -194,7 +194,7 @@ void pdlv_set_polling_finished(struct lvmpolld_lv *pdlv, unsigned finished) struct lvmpolld_store *pdst_init(const char *name) { - struct lvmpolld_store *pdst = (struct lvmpolld_store *) dm_malloc(sizeof(struct lvmpolld_store)); + struct lvmpolld_store *pdst = (struct lvmpolld_store *) malloc(sizeof(struct lvmpolld_store)); if (!pdst) return NULL; @@ -212,7 +212,7 @@ struct lvmpolld_store *pdst_init(const char *name) err_mutex: dm_hash_destroy(pdst->store); err_hash: - dm_free(pdst); + free(pdst); return NULL; } @@ -223,7 +223,7 @@ void pdst_destroy(struct lvmpolld_store *pdst) dm_hash_destroy(pdst->store); pthread_mutex_destroy(&pdst->lock); - dm_free(pdst); + free(pdst); } void pdst_locked_lock_all_pdlvs(const struct lvmpolld_store *pdst) @@ -321,7 +321,7 @@ void pdst_locked_destroy_all_pdlvs(const struct lvmpolld_store *pdst) struct lvmpolld_thread_data *lvmpolld_thread_data_constructor(struct lvmpolld_lv *pdlv) { - struct lvmpolld_thread_data *data = (struct lvmpolld_thread_data *) dm_malloc(sizeof(struct lvmpolld_thread_data)); + struct lvmpolld_thread_data *data = (struct lvmpolld_thread_data *) malloc(sizeof(struct lvmpolld_thread_data)); if (!data) return NULL; @@ -368,7 +368,7 @@ void lvmpolld_thread_data_destroy(void *thread_private) pdst_unlock(data->pdlv->pdst); } - /* may get reallocated in getline(). dm_free must not be used */ + /* may get reallocated in getline(). free must not be used */ free(data->line); if (data->fout && !fclose(data->fout)) @@ -389,5 +389,5 @@ void lvmpolld_thread_data_destroy(void *thread_private) if (data->errpipe[1] >= 0) (void) close(data->errpipe[1]); - dm_free(data); + free(data); } |