[PATCH] Planner: ascent and descent rates should be rounded rather than truncated

Linus Torvalds torvalds at linux-foundation.org
Mon Mar 13 09:07:31 PDT 2017


On Mon, Mar 13, 2017 at 12:35 AM, Rick Walsh <rickmwalsh at gmail.com> wrote:
>
>  void PlannerSettingsWidget::setAscRate75(int rate)
>  {
> -       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate * UNIT_FACTOR);
> +       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate * UNIT_FACTOR + 0.5);
>  }

These should all definitely use "lrint()" rather than " + 0.5"
together with the integer truncation.

In practice it's the same for positive values, of course, but it's the
right thing to do.

.. and this all shows that we should also enable the
-Wfloat-conversion warning for our C++ code too. Of course, it's
possible that that fails miserably for some random reason (eg "tons of
warnings from Qt header files" or whatever).

                 Linus


More information about the subsurface mailing list