summaryrefslogtreecommitdiff
path: root/apt-pkg/install-progress.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 21:51:52 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:53:48 +0100
commit0b5e329a8ba2461ccb7017d3adfc972f9dccd830 (patch)
tree61fe422eeca8c5bd5cb2de6060f11e71343d4602 /apt-pkg/install-progress.cc
parent1adcf56bec7d2127d83aa423916639740fe8e586 (diff)
deal with floats without old-style cast
We have no speed problem with handling floats/doubles in our progress handling, but that shouldn't prevent us from cleaning up the handling slightly to avoid unclean casting to ints. Reported-By: gcc -Wdouble-promotion -Wold-style-cast
Diffstat (limited to 'apt-pkg/install-progress.cc')
-rw-r--r--apt-pkg/install-progress.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 2c2205d2b..09bf465bf 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -55,8 +55,8 @@ bool PackageManager::StatusChanged(std::string /*PackageName*/,
std::string /*HumanReadableAction*/)
{
int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
- percentage = StepsDone/(float)TotalSteps * 100.0;
- strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage);
+ percentage = StepsDone/(double)TotalSteps * 100.0;
+ strprintf(progress_str, _("Progress: [%3li%%]"), std::lround(percentage));
if(percentage < (last_reported_progress + reporting_steps))
return false;
@@ -382,8 +382,8 @@ bool PackageManagerFancy::DrawStatusLine()
if (_config->FindB("Dpkg::Progress-Fancy::Progress-Bar", true))
{
int padding = 4;
- float progressbar_size = size.columns - padding - progress_str.size();
- float current_percent = percentage / 100.0;
+ auto const progressbar_size = size.columns - padding - progress_str.size();
+ auto const current_percent = percentage / 100.0;
std::cout << " "
<< GetTextProgressStr(current_percent, progressbar_size)
<< " ";