From c1b4101014742da46703b562bbc81f9b9df6ad90 Mon Sep 17 00:00:00 2001 From: yangl777 Date: Mon, 26 Jul 2021 16:36:19 +0800 Subject: [PATCH] fix build fail caused by deprecated-declarations --- ...ot-use-g_memdup-in-bd_vdo_stats_copy.patch | 101 ++++++++++++++++++ libblockdev.spec | 6 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch diff --git a/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch b/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch new file mode 100644 index 0000000..dc9fdd3 --- /dev/null +++ b/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch @@ -0,0 +1,101 @@ +From 5528baef6ccc835a06c45f9db34a2c9c3f2dd940 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 16 Mar 2021 12:05:37 +0100 +Subject: [PATCH] vdo: Do not use g_memdup in bd_vdo_stats_copy + +g_memdup is deprecated and the replacement g_memdup2 is not yet +available so lets just do the copy manually. + +Signed-off-by: Vojtech Trefny +--- + src/lib/plugin_apis/vdo.api | 17 ++++++++++++++++- + src/lib/plugin_apis/vdo.c | 17 ++++++++++++++++- + src/plugins/vdo.c | 17 ++++++++++++++++- + 3 files changed, 48 insertions(+), 3 deletions(-) + +diff --git a/src/lib/plugin_apis/vdo.api b/src/lib/plugin_apis/vdo.api +index 936f8e0..312de4e 100644 +--- a/src/lib/plugin_apis/vdo.api ++++ b/src/lib/plugin_apis/vdo.api +@@ -170,7 +170,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + * Deprecated: 2.24: Use LVM-VDO integration instead. + */ + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + GType bd_vdo_stats_get_type () { +diff --git a/src/lib/plugin_apis/vdo.c b/src/lib/plugin_apis/vdo.c +index 40563ee..3e23bbc 100644 +--- a/src/lib/plugin_apis/vdo.c ++++ b/src/lib/plugin_apis/vdo.c +@@ -106,7 +106,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + * Deprecated: 2.24: Use LVM-VDO integration instead. + */ + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + GType bd_vdo_stats_get_type () { +diff --git a/src/plugins/vdo.c b/src/plugins/vdo.c +index 2352394..a9eb54a 100644 +--- a/src/plugins/vdo.c ++++ b/src/plugins/vdo.c +@@ -81,7 +81,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + } + + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + +-- +2.27.0 diff --git a/libblockdev.spec b/libblockdev.spec index 116bc18..a4a9f4b 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -1,6 +1,6 @@ Name: libblockdev Version: 2.24 -Release: 5 +Release: 6 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev @@ -21,6 +21,7 @@ Patch12: 0012-kbd-Fix-memory-leak.patch Patch13: 0013-lvm-dbus-Fix-memory-leak.patch Patch14: 0014-mdraid-Fix-memory-leak.patch Patch15: 0015-swap-Fix-memory-leak.patch +Patch16: 0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch BuildRequires: git glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel dmraid-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel @@ -171,6 +172,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Mon Jul 26 2020 yanglongkang - 2.24-6 +- fix build fail caused by deprecated-declarations + * Sat Oct 31 2020 Zhiqiang Liu - 2.24-5 - backport upstream patches-epoch2 to fix serveral problems -- Gitee