[lvm-devel] master - libdm: make dm_stats_destroy(NULL) a no-op
Bryn Reeves
bmr at sourceware.org
Fri Mar 10 16:44:52 UTC 2017
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d28a50ec76c62c48a3be695569fe5e752b9ae684
Commit: d28a50ec76c62c48a3be695569fe5e752b9ae684
Parent: 93644be44b4067c6ebc1d450589ca510129b3b60
Author: Bryn M. Reeves <bmr at redhat.com>
AuthorDate: Fri Mar 10 16:41:28 2017 +0000
Committer: Bryn M. Reeves <bmr at redhat.com>
CommitterDate: Fri Mar 10 16:41:28 2017 +0000
libdm: make dm_stats_destroy(NULL) a no-op
Test for NULL in dm_stats_destroy() and return immediately if
the struct dm_stats pointer is NULL (similar to free(NULL)).
This simplifies cleanup code which otherwise needs to:
out:
if (dms)
dm_stats_destroy(dms);
return;
---
libdm/libdm-stats.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 61c052f..c83c27b 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -2387,6 +2387,9 @@ bad:
*/
void dm_stats_destroy(struct dm_stats *dms)
{
+ if (!dms)
+ return;
+
_stats_regions_destroy(dms);
_stats_groups_destroy(dms);
_stats_clear_binding(dms);
More information about the lvm-devel
mailing list