From 9d9de35dca9b9f7964b884ffc250e24f6c84c783 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 20 Dec 2010 13:32:49 +0000 Subject: [PATCH] Remove const usage from destroy callbacks As const segment_type or const format_type are never released use their non-const version and remove const downcast from dm_free calls. This change fixes many gcc warnings we were getting from them. --- lib/error/errseg.c | 4 ++-- lib/format1/format1.c | 4 ++-- lib/format_pool/format_pool.c | 4 ++-- lib/format_text/format-text.c | 4 ++-- lib/freeseg/freeseg.c | 4 ++-- lib/metadata/metadata.h | 2 +- lib/metadata/segtype.h | 2 +- lib/mirror/mirrored.c | 4 ++-- lib/replicator/replicator.c | 4 ++-- lib/snapshot/snapshot.c | 4 ++-- lib/striped/striped.c | 4 ++-- lib/unknown/unknown.c | 4 ++-- lib/zero/zero.c | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/error/errseg.c b/lib/error/errseg.c index 6cfcd794b..add1df8cb 100644 --- a/lib/error/errseg.c +++ b/lib/error/errseg.c @@ -81,9 +81,9 @@ static int _errseg_modules_needed(struct dm_pool *mem, return 1; } -static void _errseg_destroy(const struct segment_type *segtype) +static void _errseg_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _error_ops = { diff --git a/lib/format1/format1.c b/lib/format1/format1.c index 0dcec053d..b35bd9874 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -555,9 +555,9 @@ static void _format1_destroy_instance(struct format_instance *fid __attribute__( { } -static void _format1_destroy(const struct format_type *fmt) +static void _format1_destroy(struct format_type *fmt) { - dm_free((void *) fmt); + dm_free(fmt); } static struct format_handler _format1_ops = { diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c index 545195bb7..730da87f5 100644 --- a/lib/format_pool/format_pool.c +++ b/lib/format_pool/format_pool.c @@ -286,9 +286,9 @@ static void _pool_destroy_instance(struct format_instance *fid __attribute__((un { } -static void _pool_destroy(const struct format_type *fmt) +static void _pool_destroy(struct format_type *fmt) { - dm_free((void *) fmt); + dm_free(fmt); } /* *INDENT-OFF* */ diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index caab9236b..c186757ee 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1719,7 +1719,7 @@ static void _free_raws(struct dm_list *raw_list) } } -static void _text_destroy(const struct format_type *fmt) +static void _text_destroy(struct format_type *fmt) { if (fmt->private) { _free_dirs(&((struct mda_lists *) fmt->private)->dirs); @@ -1727,7 +1727,7 @@ static void _text_destroy(const struct format_type *fmt) dm_free(fmt->private); } - dm_free((void *)fmt); + dm_free(fmt); } static struct metadata_area_ops _metadata_text_file_ops = { diff --git a/lib/freeseg/freeseg.c b/lib/freeseg/freeseg.c index 08f310067..8e73be0c6 100644 --- a/lib/freeseg/freeseg.c +++ b/lib/freeseg/freeseg.c @@ -31,9 +31,9 @@ static const char *_freeseg_name(const struct lv_segment *seg) return seg->segtype->name; } -static void _freeseg_destroy(const struct segment_type *segtype) +static void _freeseg_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _freeseg_ops = { diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 815e4600a..08bff4a7e 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -291,7 +291,7 @@ struct format_handler { /* * Destructor for format type */ - void (*destroy) (const struct format_type * fmt); + void (*destroy) (struct format_type * fmt); }; /* diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index 8bf16d740..6d50746b2 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -97,7 +97,7 @@ struct segtype_handler { int (*modules_needed) (struct dm_pool *mem, const struct lv_segment *seg, struct dm_list *modules); - void (*destroy) (const struct segment_type * segtype); + void (*destroy) (struct segment_type * segtype); int (*target_monitored) (struct lv_segment *seg, int *pending); int (*target_monitor_events) (struct lv_segment *seg, int events); int (*target_unmonitor_events) (struct lv_segment *seg, int events); diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c index a02ccb5af..3d25d7092 100644 --- a/lib/mirror/mirrored.c +++ b/lib/mirror/mirrored.c @@ -600,9 +600,9 @@ static int _mirrored_modules_needed(struct dm_pool *mem, return 1; } -static void _mirrored_destroy(const struct segment_type *segtype) +static void _mirrored_destroy(struct segment_type *segtype) { - dm_free((void *) segtype); + dm_free(segtype); } static struct segtype_handler _mirrored_ops = { diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c index 1753bcafa..26a5cf1c0 100644 --- a/lib/replicator/replicator.c +++ b/lib/replicator/replicator.c @@ -406,9 +406,9 @@ static int _replicator_modules_needed(struct dm_pool *mem, return 1; } -static void _replicator_destroy(const struct segment_type *segtype) +static void _replicator_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _replicator_ops = { diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c index e1612f992..1a98d7e0d 100644 --- a/lib/snapshot/snapshot.c +++ b/lib/snapshot/snapshot.c @@ -218,9 +218,9 @@ static int _snap_modules_needed(struct dm_pool *mem, return 1; } -static void _snap_destroy(const struct segment_type *segtype) +static void _snap_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _snapshot_ops = { diff --git a/lib/striped/striped.c b/lib/striped/striped.c index 7ba963bf0..51bf24a1e 100644 --- a/lib/striped/striped.c +++ b/lib/striped/striped.c @@ -199,9 +199,9 @@ static int _striped_target_present(struct cmd_context *cmd, } #endif -static void _striped_destroy(const struct segment_type *segtype) +static void _striped_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _striped_ops = { diff --git a/lib/unknown/unknown.c b/lib/unknown/unknown.c index 6dc00f666..332ae99e0 100644 --- a/lib/unknown/unknown.c +++ b/lib/unknown/unknown.c @@ -74,9 +74,9 @@ static int _unknown_add_target_line(struct dev_manager *dm __attribute__((unused } #endif -static void _unknown_destroy(const struct segment_type *segtype) +static void _unknown_destroy(struct segment_type *segtype) { - dm_free((void *)segtype); + dm_free(segtype); } static struct segtype_handler _unknown_ops = { diff --git a/lib/zero/zero.c b/lib/zero/zero.c index 7e5ffa6a3..16ce66c40 100644 --- a/lib/zero/zero.c +++ b/lib/zero/zero.c @@ -78,9 +78,9 @@ static int _zero_modules_needed(struct dm_pool *mem, return 1; } -static void _zero_destroy(const struct segment_type *segtype) +static void _zero_destroy(struct segment_type *segtype) { - dm_free((void *) segtype); + dm_free(segtype); } static struct segtype_handler _zero_ops = {