From c3be38af7289324a249e26a6fd4397a0828e032c Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 2 Nov 2018 13:26:29 -0400 Subject: [PATCH] postprocess: Minor glnx_console interaction fixes Make sure we always pass an integer and not a float to `glnx_console_progress_text_percent`. And also make sure we clamp the value we pass to 100. Not sure how I hit this, somehow the byte counting we do upfront before committing is *less* than the addition of all the `g_file_info_get_size()`s? Closes: #1658 Approved by: cgwalters --- src/libpriv/rpmostree-postprocess.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index 435e56be..73e1e09d 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -2018,7 +2018,8 @@ on_progress_timeout (gpointer datap) struct CommitThreadData *data = datap; const gint percent = g_atomic_int_get (&data->percent); - glnx_console_progress_text_percent ("Committing:", percent); + /* clamp to 100 if it somehow goes over (XXX: bad counting?) */ + glnx_console_progress_text_percent ("Committing:", MIN(percent, 100)); return TRUE; } @@ -2100,7 +2101,7 @@ rpmostree_compose_commit (int rootfs_fd, while (g_atomic_int_get (&tdata.done) == 0) g_main_context_iteration (NULL, TRUE); - glnx_console_progress_text_percent ("Committing:", 100.0); + glnx_console_progress_text_percent ("Committing:", 100); glnx_console_unlock (&console); g_thread_join (g_steal_pointer (&commit_thread));