1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-01 03:22:30 +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

@@ -261,28 +261,28 @@ int wGetHeadRelativeToCurrentHead(WScreen *scr, int current_head, int direction)
case DIRECTION_LEFT:
if (rect->pos.x < crect.pos.x) {
found = 1;
distance = abs((rect->pos.x + rect->size.width)
distance = abs((rect->pos.x + (int)rect->size.width)
- crect.pos.x) + abs(rect->pos.y + crect.pos.y);
}
break;
case DIRECTION_RIGHT:
if (rect->pos.x > crect.pos.x) {
found = 1;
distance = abs((crect.pos.x + crect.size.width)
distance = abs((crect.pos.x + (int)crect.size.width)
- rect->pos.x) + abs(rect->pos.y + crect.pos.y);
}
break;
case DIRECTION_UP:
if (rect->pos.y < crect.pos.y) {
found = 1;
distance = abs((rect->pos.y + rect->size.height)
distance = abs((rect->pos.y + (int)rect->size.height)
- crect.pos.y) + abs(rect->pos.x + crect.pos.x);
}
break;
case DIRECTION_DOWN:
if (rect->pos.y > crect.pos.y) {
found = 1;
distance = abs((crect.pos.y + crect.size.height)
distance = abs((crect.pos.y + (int)crect.size.height)
- rect->pos.y) + abs(rect->pos.x + crect.pos.x);
}
break;