diff --git a/cmdline/dup.c b/cmdline/dup.c index 873be3f8..39e3b66e 100644 --- a/cmdline/dup.c +++ b/cmdline/dup.c @@ -60,8 +60,10 @@ static inline tommy_uint32_t hash_hash(struct snapraid_hash* hash) return tommy_hash_u32(0, hash->hash, HASH_MAX); } -void hash_free(struct snapraid_hash* hash) +static void hash_free(void* void_hash) { + struct snapraid_hash* hash = void_hash; + free(hash); } @@ -122,7 +124,7 @@ void state_dup(struct snapraid_state* state) } } - tommy_hashdyn_foreach(&hashset, (tommy_foreach_func*)hash_free); + tommy_hashdyn_foreach(&hashset, hash_free); tommy_hashdyn_done(&hashset); msg_status("\n"); diff --git a/cmdline/elem.c b/cmdline/elem.c index c5b13d96..ac192970 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -24,8 +24,10 @@ struct snapraid_content* content_alloc(const char* path, uint64_t dev) return content; } -void content_free(struct snapraid_content* content) +void content_free(void* void_content) { + struct snapraid_content* content = void_content; + free(content); } @@ -453,8 +455,10 @@ struct snapraid_file* file_dup(struct snapraid_file* copy) return file; } -void file_free(struct snapraid_file* file) +void file_free(void* void_file) { + struct snapraid_file* file = void_file; + free(file->sub); file->sub = 0; free(file->blockvec); @@ -679,8 +683,10 @@ struct snapraid_extent* extent_alloc(block_off_t parity_pos, struct snapraid_fil return extent; } -void extent_free(struct snapraid_extent* extent) +void extent_free(void* void_extent) { + struct snapraid_extent* extent = void_extent; + free(extent); } @@ -730,8 +736,10 @@ struct snapraid_link* link_alloc(const char* sub, const char* linkto, unsigned l return slink; } -void link_free(struct snapraid_link* slink) +void link_free(void* void_link) { + struct snapraid_link* slink = void_link; + free(slink->sub); free(slink->linkto); free(slink); @@ -764,8 +772,10 @@ struct snapraid_dir* dir_alloc(const char* sub) return dir; } -void dir_free(struct snapraid_dir* dir) +void dir_free(void* void_dir) { + struct snapraid_dir* dir = void_dir; + free(dir->sub); free(dir); } @@ -820,8 +830,10 @@ void dealloc_import(struct snapraid_dealloc* dealloc, struct snapraid_file* file } } -void dealloc_free(struct snapraid_dealloc* dealloc) +void dealloc_free(void* void_dealloc) { + struct snapraid_dealloc* dealloc = void_dealloc; + free(dealloc->sub); free(dealloc->blockhash); free(dealloc); @@ -890,19 +902,21 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev return disk; } -void disk_free(struct snapraid_disk* disk) +void disk_free(void* void_disk) { - tommy_list_foreach(&disk->filelist, (tommy_foreach_func*)file_free); - tommy_list_foreach(&disk->deletedlist, (tommy_foreach_func*)file_free); - tommy_tree_foreach(&disk->fs_file, (tommy_foreach_func*)extent_free); + struct snapraid_disk* disk = void_disk; + + tommy_list_foreach(&disk->filelist, file_free); + tommy_list_foreach(&disk->deletedlist, file_free); + tommy_tree_foreach(&disk->fs_file, extent_free); tommy_hashdyn_done(&disk->inodeset); tommy_hashdyn_done(&disk->pathset); tommy_hashdyn_done(&disk->stampset); - tommy_list_foreach(&disk->linklist, (tommy_foreach_func*)link_free); + tommy_list_foreach(&disk->linklist, link_free); tommy_hashdyn_done(&disk->linkset); - tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free); + tommy_list_foreach(&disk->dirlist, dir_free); tommy_hashdyn_done(&disk->dirset); - tommy_list_foreach(&disk->dealloclist, (tommy_foreach_func*)dealloc_free); + tommy_list_foreach(&disk->dealloclist, dealloc_free); #if HAVE_THREAD thread_mutex_destroy(&disk->fs_mutex); @@ -937,8 +951,10 @@ struct snapraid_extra* extra_alloc(const char* name, const char* dir, uint64_t d return extra; } -void extra_free(struct snapraid_extra* extra) +void extra_free(void* void_extra) { + struct snapraid_extra* extra = void_extra; + free(extra); } @@ -1565,8 +1581,10 @@ struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t return map; } -void map_free(struct snapraid_map* map) +void map_free(void* void_map) { + struct snapraid_map* map = void_map; + free(map); } @@ -1584,8 +1602,10 @@ static int bucket_cmp(const void* void_a, const void* void_b) return 0; } -void bucket_free(struct snapraid_bucket* bucket) +void bucket_free(void* void_bucket) { + struct snapraid_bucket* bucket = void_bucket; + free(bucket); } @@ -1621,7 +1641,7 @@ void bucket_insert(tommy_hashdyn* bucket_hash, time_t time_at, block_off_t count void bucket_to_list(tommy_hashdyn* bucket_hash, tommy_list* bucket_list, block_off_t* bucketcount) { /* clear previous list */ - tommy_list_foreach(bucket_list, (tommy_foreach_func*)bucket_free); + tommy_list_foreach(bucket_list, bucket_free); tommy_list_init(bucket_list); log_tag("list:bucket_begin\n"); diff --git a/cmdline/elem.h b/cmdline/elem.h index 73b67468..e4a1f097 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -574,7 +574,7 @@ struct snapraid_content* content_alloc(const char* path, uint64_t dev); /** * Deallocate a content. */ -void content_free(struct snapraid_content* content); +void content_free(void* void_content); /** * Allocate a filter pattern for files and directories. @@ -850,7 +850,7 @@ struct snapraid_file* file_dup(struct snapraid_file* copy); /** * Deallocate a file. */ -void file_free(struct snapraid_file* file); +void file_free(void* void_file); /** * Rename a file. @@ -955,7 +955,7 @@ struct snapraid_extent* extent_alloc(block_off_t parity_pos, struct snapraid_fil /** * Deallocate a extent. */ -void extent_free(struct snapraid_extent* extent); +void extent_free(void* void_extent); /** * Compare extent by parity position. @@ -1001,7 +1001,7 @@ struct snapraid_link* link_alloc(const char* name, const char* slink, unsigned l /** * Deallocate a link. */ -void link_free(struct snapraid_link* slink); +void link_free(void* void_link); /** * Compare a link with a name. @@ -1044,7 +1044,7 @@ struct snapraid_dir* dir_alloc(const char* name); /** * Deallocate a dir. */ -void dir_free(struct snapraid_dir* dir); +void dir_free(void* void_dir); /** * Compare a dir with a name. @@ -1067,7 +1067,7 @@ struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, dat /** * Deallocate a dealloc. */ -void dealloc_free(struct snapraid_dealloc* dealloc); +void dealloc_free(void* void_dealloc); /** * Import file hash in the dealloc. @@ -1082,7 +1082,7 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev /** * Deallocate a disk. */ -void disk_free(struct snapraid_disk* disk); +void disk_free(void* void_disk); /** * Allocate a extra disk. @@ -1092,7 +1092,7 @@ struct snapraid_extra* extra_alloc(const char* name, const char* dir, uint64_t d /** * Deallocate a other disk. */ -void extra_free(struct snapraid_extra* other); +void extra_free(void* void_extra); /** * Get the size of the disk in blocks. @@ -1219,7 +1219,7 @@ struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t /** * Deallocate a disk mapping. */ -void map_free(struct snapraid_map* map); +void map_free(void* void_map); /** * Mask used to store additional information in the info bits. @@ -1335,7 +1335,7 @@ struct snapraid_bucket { tommy_node node; }; -void bucket_free(struct snapraid_bucket* bucket); +void bucket_free(void* void_bucket); /** * Insert an bucket record into the hashtable diff --git a/cmdline/import.c b/cmdline/import.c index a50cfa9c..40df5f52 100644 --- a/cmdline/import.c +++ b/cmdline/import.c @@ -204,8 +204,10 @@ static void import_dealloc(struct snapraid_state* state, const char* dir, struct tommy_list_insert_tail(&state->importlist, &file->nodelist, file); } -void import_file_free(struct snapraid_import_file* file) +void import_file_free(void* void_file) { + struct snapraid_import_file* file = void_file; + free(file->path); free(file->blockimp); free(file); diff --git a/cmdline/import.h b/cmdline/import.h index fcc7f34a..8aef9b0d 100644 --- a/cmdline/import.h +++ b/cmdline/import.h @@ -44,7 +44,7 @@ struct snapraid_import_file { /** * Deallocate an import file. */ -void import_file_free(struct snapraid_import_file* file); +void import_file_free(void* void_file); /** * Fetch a block from the specified hash. diff --git a/cmdline/pool.c b/cmdline/pool.c index d3707d92..8e504ce5 100644 --- a/cmdline/pool.c +++ b/cmdline/pool.c @@ -35,8 +35,10 @@ static inline tommy_uint32_t pool_hash(const char* file) return tommy_hash_u32(0, file, strlen(file)); } -void pool_free(struct snapraid_pool* pool) +static void pool_free(void* void_pool) { + struct snapraid_pool* pool = void_pool; + free(pool); } @@ -442,12 +444,12 @@ void state_pool(struct snapraid_state* state) msg_progress("Cleaning...\n"); /* delete all the remaining links */ - tommy_hashdyn_foreach_arg(&poolset, (tommy_foreach_arg_func*)remove_link, pool_dir); + tommy_hashdyn_foreach_arg(&poolset, remove_link, pool_dir); /* delete empty dirs */ clean_dir(pool_dir); - tommy_hashdyn_foreach(&poolset, (tommy_foreach_func*)pool_free); + tommy_hashdyn_foreach(&poolset, pool_free); tommy_hashdyn_done(&poolset); if (count) diff --git a/cmdline/scan.c b/cmdline/scan.c index 2d22d914..998f0c99 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -74,8 +74,9 @@ static struct snapraid_scan* scan_alloc(struct snapraid_state* state, struct sna return scan; } -static void scan_free(struct snapraid_scan* scan) +static void scan_free(void* void_scan) { + struct snapraid_scan* scan = void_scan; #if HAVE_THREAD thread_mutex_destroy(&scan->disk->stamp_mutex); #endif @@ -2249,7 +2250,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) log_flush(); - tommy_list_foreach(&scanlist, (tommy_foreach_func*)scan_free); + tommy_list_foreach(&scanlist, scan_free); /* check the file-system on all disks */ state_fscheck(state, "after scan"); diff --git a/cmdline/search.c b/cmdline/search.c index 59b01c89..6d614e36 100644 --- a/cmdline/search.c +++ b/cmdline/search.c @@ -25,8 +25,10 @@ static void search_file(struct snapraid_state* state, const char* path, data_off tommy_hashdyn_insert(&state->searchset, &file->node, file, file_hash); } -void search_file_free(struct snapraid_search_file* file) +void search_file_free(void* void_file) { + struct snapraid_search_file* file = void_file; + free(file->path); free(file); } diff --git a/cmdline/search.h b/cmdline/search.h index 6eb8d62c..55c8fef3 100644 --- a/cmdline/search.h +++ b/cmdline/search.h @@ -28,7 +28,7 @@ struct snapraid_search_file { /** * Deallocate a search file. */ -void search_file_free(struct snapraid_search_file* file); +void search_file_free(void* void_file); /** * Fetch a file from the size, timestamp and name. diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 90612556..7a8c3196 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -2131,8 +2131,8 @@ int snapraid_main(int argc, char* argv[]) #endif state_done(&state); - tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); - tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); + tommy_list_foreach(&filterlist_file, filter_free); + tommy_list_foreach(&filterlist_disk, filter_free); app_done(); os_done(); diff --git a/cmdline/state.c b/cmdline/state.c index 18cb85ab..14946845 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -202,19 +202,19 @@ void state_init(struct snapraid_state* state) void state_done(struct snapraid_state* state) { - tommy_list_foreach(&state->disklist, (tommy_foreach_func*)disk_free); - tommy_list_foreach(&state->extralist, (tommy_foreach_func*)extra_free); - tommy_list_foreach(&state->maplist, (tommy_foreach_func*)map_free); - tommy_list_foreach(&state->contentlist, (tommy_foreach_func*)content_free); - tommy_list_foreach(&state->filterlist, (tommy_foreach_func*)filter_free); - tommy_list_foreach(&state->importlist, (tommy_foreach_func*)import_file_free); - tommy_list_foreach(&state->thermallist, (tommy_foreach_func*)thermal_free); - tommy_hashdyn_foreach(&state->searchset, (tommy_foreach_func*)search_file_free); + tommy_list_foreach(&state->disklist, disk_free); + tommy_list_foreach(&state->extralist, extra_free); + tommy_list_foreach(&state->maplist, map_free); + tommy_list_foreach(&state->contentlist, content_free); + tommy_list_foreach(&state->filterlist, filter_free); + tommy_list_foreach(&state->importlist, import_file_free); + tommy_list_foreach(&state->thermallist, thermal_free); + tommy_hashdyn_foreach(&state->searchset, search_file_free); tommy_hashdyn_done(&state->importset); tommy_hashdyn_done(&state->previmportset); tommy_hashdyn_done(&state->searchset); tommy_arrayblkof_done(&state->infoarr); - tommy_list_foreach(&state->bucketlist, (tommy_foreach_func*)bucket_free); + tommy_list_foreach(&state->bucketlist, bucket_free); } /** @@ -4149,7 +4149,7 @@ static void* state_write_thread(void* arg) return 0; bail: - tommy_hashdyn_foreach(&bucket_hash, (tommy_foreach_func*)bucket_free); + tommy_hashdyn_foreach(&bucket_hash, bucket_free); tommy_hashdyn_done(&bucket_hash); return context; } @@ -5017,7 +5017,7 @@ void state_commit(struct snapraid_state* state) if (!tommy_list_empty(&disk->dealloclist)) { /* clear the dealloc list */ - tommy_list_foreach(&disk->dealloclist, (tommy_foreach_func*)dealloc_free); + tommy_list_foreach(&disk->dealloclist, dealloc_free); tommy_list_init(&disk->dealloclist); /* mark the state as needing write */ diff --git a/cmdline/thermal.c b/cmdline/thermal.c index 53199f01..36ee1926 100644 --- a/cmdline/thermal.c +++ b/cmdline/thermal.c @@ -22,8 +22,10 @@ struct snapraid_thermal* thermal_alloc(uint64_t dev, const char* name) return thermal; } -void thermal_free(struct snapraid_thermal* thermal) +void thermal_free(void* void_thermal) { + struct snapraid_thermal* thermal = void_thermal; + free(thermal); } diff --git a/cmdline/thermal.h b/cmdline/thermal.h index 82fe8f61..5e23ddb3 100644 --- a/cmdline/thermal.h +++ b/cmdline/thermal.h @@ -56,7 +56,7 @@ struct snapraid_thermal* thermal_alloc(uint64_t dev, const char* name); /** * Deallocate a thermal state. */ -void thermal_free(struct snapraid_thermal* thermal); +void thermal_free(void* void_thermal); #endif