mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +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:
committed by
Carlos R. Mafra
parent
dfa92906c0
commit
44bc9cc264
@@ -22,6 +22,7 @@
|
||||
#include "WPrefs.h"
|
||||
#include <unistd.h>
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include <math.h>
|
||||
|
||||
/* workaround for older fontconfig, that doesn't define these constants */
|
||||
#ifndef FC_WEIGHT_NORMAL
|
||||
@@ -521,7 +522,7 @@ static void selectedOption(WMWidget * w, void *data)
|
||||
WMListItem *item = WMGetListItem(panel->sizeL, i);
|
||||
int distance;
|
||||
|
||||
distance = abs(size - atoi(item->text));
|
||||
distance = fabs(size - atoi(item->text));
|
||||
|
||||
if (i == 0 || distance < closest) {
|
||||
closest = distance;
|
||||
|
||||
Reference in New Issue
Block a user