1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-30 18:32:34 +01:00

Fix various abs() issues.

The abs() function should take an int as argument, but there were
several instances in the code where it was taking an unsigned int or a
double.  In these case, we took one of the following approaches:

* If the argument was a double, use fabs() instead.
* If the argument was unsigned and was certainly going to be positive
  (i.e,. no subtraction), then drop abs() altogether.
* If the argument was unsigned as result of adding or subtracting signed
  and unsigned ints, then we cast all the unsigned ints to signed ints.
This commit is contained in:
Doug Torrance
2020-04-18 14:28:41 -04:00
committed by Carlos R. Mafra
parent dfa92906c0
commit 44bc9cc264
5 changed files with 12 additions and 11 deletions

View File

@@ -1436,7 +1436,7 @@ static void getScrollAmount(WMenu * menu, int *hamount, int *vamount)
} else if (xroot >= (rect.pos.x + rect.size.width - 2) && menuX2 > (rect.pos.x + rect.size.width - 1)) {
/* scroll to the left */
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2 - rect.pos.x - rect.size.width - 1));
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2 - rect.pos.x - (int)rect.size.width - 1));
if (*hamount == 0)
*hamount = 1;
@@ -1450,7 +1450,7 @@ static void getScrollAmount(WMenu * menu, int *hamount, int *vamount)
} else if (yroot >= (rect.pos.y + rect.size.height - 2) && menuY2 > (rect.pos.y + rect.size.height - 1)) {
/* scroll up */
*vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2 - rect.pos.y - rect.size.height - 2));
*vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2 - rect.pos.y - (int)rect.size.height - 2));
*vamount = -*vamount;
}