From 043f58452a0a2c136dd6a90f1d60b063ae17a866 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 14 Mar 2018 21:00:46 +0100 Subject: [PATCH] libdm-stats: fix error messages When function dm_stats_populate() returns 0 it's an error and needs log_error() message - function can't have 'success' returning 0 or error without reasons. --- WHATS_NEW_DM | 1 + libdm/libdm-stats.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 2fafe74be..34c68332c 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.147 - ===================================== + Add missing log_error() into dm_stats_populate() returning 0. Avoid calling dm_stats_populat() for DM devices without any stats regions. Support DM_DEBUG_WITH_LINE_NUMBERS envvar for debug msg with source:line. Configured command for thin pool threshold handling gets whole environment. diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index c74444a5e..94ad380e0 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -403,7 +403,7 @@ static int _stats_bound(const struct dm_stats *dms) if (dms->bind_major > 0 || dms->bind_name || dms->bind_uuid) return 1; /* %p format specifier expects a void pointer. */ - log_debug("Stats handle at %p is not bound.", dms); + log_error("Stats handle at %p is not bound.", dms); return 0; } @@ -2336,6 +2336,11 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id, return 0; } + if (!dms->nr_regions) { + log_error("No regions registered."); + return 0; + } + /* allow zero-length program_id for populate */ if (!program_id) program_id = dms->program_id; @@ -2347,10 +2352,6 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id, goto_bad; } - /* successful list but no regions registered */ - if (!dms->nr_regions) - return 0; - dms->walk_flags = DM_STATS_WALK_REGION; dm_stats_walk_start(dms); do { -- 2.43.5