Change copy_percent to return status (one of TARGET_STATUS_ macros) and to return float variable by reference. So that there are no more decisions made based on the comparison of floating point value. Signed-off-by: Mikulas Patocka --- lib/metadata/metadata-exported.h | 2 +- lib/metadata/mirror.c | 6 ++++-- lib/report/report.c | 2 +- tools/polldaemon.c | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) Index: LVM2.2.02.53/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.53.orig/lib/metadata/metadata-exported.h 2009-10-01 20:37:21.000000000 +0200 +++ LVM2.2.02.53/lib/metadata/metadata-exported.h 2009-10-01 20:37:28.000000000 +0200 @@ -685,7 +685,7 @@ struct logical_volume *find_pvmove_lv_fr uint32_t lv_type); const char *get_pvmove_pvname_from_lv(struct logical_volume *lv); const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr); -float copy_percent(struct logical_volume *lv_mirr); +int copy_percent(struct logical_volume *lv_mirr, float *percent); struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv); Index: LVM2.2.02.53/lib/metadata/mirror.c =================================================================== --- LVM2.2.02.53.orig/lib/metadata/mirror.c 2009-10-01 20:37:27.000000000 +0200 +++ LVM2.2.02.53/lib/metadata/mirror.c 2009-10-01 20:37:28.000000000 +0200 @@ -1113,7 +1113,7 @@ struct dm_list *lvs_using_lv(struct cmd_ return lvs; } -float copy_percent(struct logical_volume *lv_mirr) +int copy_percent(struct logical_volume *lv_mirr, float *percent) { uint32_t numerator = 0u, denominator = 0u; struct lv_segment *seg; @@ -1127,7 +1127,9 @@ float copy_percent(struct logical_volume numerator += seg->area_len; } - return denominator ? (float) numerator *100 / denominator : 100.0; + *percent = denominator ? (float) numerator *100 / denominator : 100.0; + return denominator == numerator ? TARGET_STATUS_FINISHED + : TARGET_STATUS_PROCESSING; } /* Index: LVM2.2.02.53/lib/report/report.c =================================================================== --- LVM2.2.02.53.orig/lib/report/report.c 2009-10-01 20:37:27.000000000 +0200 +++ LVM2.2.02.53/lib/report/report.c 2009-10-01 20:37:28.000000000 +0200 @@ -1073,7 +1073,7 @@ static int _copypercent_disp(struct dm_r return 1; } - percent = copy_percent(lv); + copy_percent(lv, &percent); if (!(repstr = dm_pool_zalloc(mem, 8))) { log_error("dm_pool_alloc failed"); Index: LVM2.2.02.53/tools/polldaemon.c =================================================================== --- LVM2.2.02.53.orig/tools/polldaemon.c 2009-10-01 20:37:27.000000000 +0200 +++ LVM2.2.02.53/tools/polldaemon.c 2009-10-01 20:37:28.000000000 +0200 @@ -71,7 +71,7 @@ static int _check_mirror_status(struct c { struct dm_list *lvs_changed; float segment_percent = 0.0, overall_percent = 0.0; - int status; + int status, overall_status; uint32_t event_nr = 0; /* By default, caller should not retry */ @@ -93,7 +93,7 @@ static int _check_mirror_status(struct c return 0; } - overall_percent = copy_percent(lv_mirr); + overall_status = copy_percent(lv_mirr, &overall_percent); if (parms->progress_display) log_print("%s: %s: %.1f%%", name, parms->progress_title, overall_percent); @@ -113,7 +113,7 @@ static int _check_mirror_status(struct c } /* Finished? Or progress to next segment? */ - if (overall_percent >= 100.0) { + if (overall_status == TARGET_STATUS_FINISHED) { if (!parms->poll_fns->finish_copy(cmd, vg, lv_mirr, lvs_changed)) return 0;