[haiku-commits] Re: haiku.: hrev-51957 - in src/servers/app/drawing/interface/local: . src/servers/app

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 May 2018 19:56:00 +0200

Hi,

2018-05-22 9:38 GMT+02:00 Stephan Aßmus <superstippi@xxxxxx>:

Am 20.05.2018 um 22:38 schrieb waddlesplash:

diff --git a/src/servers/app/Screen.cpp b/src/servers/app/Screen.cpp
index 0fc58008bd..9ae34015e6 100644
--- a/src/servers/app/Screen.cpp
+++ b/src/servers/app/Screen.cpp
@@ -265,7 +265,7 @@ Screen::_FindBestMode(const display_mode* modes,
uint32 count,
                // TODO: check if these scores make sense
                int32 diff = 1000 * abs(mode.timing.v_display - height)
                        + int32(fabs(get_mode_frequency(mode) - frequency)
* 10)
-                       + 100 * abs(mode.space - colorSpace);
+                       + 100 * abs((int)(mode.space - colorSpace));


This doesn't look right to me. Since this just computes a score, it probably
doesn't matter, but the cast to int should probably happen like this:

+ 100 * abs((int)mode.space - colorSpace);

This makes the computation happen with ints. Otherwise abs() shouldn't be
needed in the first place, if the result is unsigned.

+1.

As commented on the change, the call with "abs(mode.timing.v_display -
height)" is not affected, a uint16 is promoted to int. But IMO it
would be better to explicit cast to int.

Bye,
Jérôme

Other related posts: