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.39/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.39.orig/lib/metadata/metadata-exported.h 2008-08-04 19:23:12.000000000 +0200 +++ LVM2.2.02.39/lib/metadata/metadata-exported.h 2008-08-04 19:38:25.000000000 +0200 @@ -538,7 +538,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 list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv); Index: LVM2.2.02.39/lib/metadata/mirror.c =================================================================== --- LVM2.2.02.39.orig/lib/metadata/mirror.c 2008-08-04 19:25:00.000000000 +0200 +++ LVM2.2.02.39/lib/metadata/mirror.c 2008-08-04 19:38:25.000000000 +0200 @@ -1052,7 +1052,7 @@ struct list *lvs_using_lv(struct cmd_con 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; @@ -1066,7 +1066,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.39/lib/report/report.c =================================================================== --- LVM2.2.02.39.orig/lib/report/report.c 2008-08-04 19:25:00.000000000 +0200 +++ LVM2.2.02.39/lib/report/report.c 2008-08-04 19:38:25.000000000 +0200 @@ -1004,7 +1004,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.39/tools/polldaemon.c =================================================================== --- LVM2.2.02.39.orig/tools/polldaemon.c 2008-08-04 19:36:34.000000000 +0200 +++ LVM2.2.02.39/tools/polldaemon.c 2008-08-04 19:38:25.000000000 +0200 @@ -70,7 +70,7 @@ static int _check_mirror_status(struct c { struct 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 */ @@ -92,7 +92,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); @@ -112,7 +112,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;