casting to long is brittle because it's different for 32 bit arches,

use sturdier absdiff instead
This commit is contained in:
espie 2017-07-28 15:45:08 +00:00
parent ff3f872d64
commit c4c319773c
2 changed files with 20 additions and 7 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.30 2017/07/26 22:45:28 sthen Exp $
# $OpenBSD: Makefile,v 1.31 2017/07/28 15:45:08 espie Exp $
COMMENT= Sandia Internet path characterization tool
DISTNAME= pchar-1.5
REVISION = 2
REVISION = 3
CATEGORIES= net
MASTER_SITES= ${HOMEPAGE}

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-ResultTable_cc,v 1.1 2017/05/08 21:40:10 naddy Exp $
$OpenBSD: patch-ResultTable_cc,v 1.2 2017/07/28 15:45:08 espie Exp $
Index: ResultTable.cc
--- ResultTable.cc.orig
@ -12,21 +12,34 @@ Index: ResultTable.cc
if (data == NULL) {
fprintf(stderr, "Couldn't allocate data array for a ResultTable\n");
exit(1);
@@ -909,7 +909,7 @@ void ResultTable::lmsint(double &a, double &b, double
@@ -767,6 +767,12 @@ void ResultTable::lms(double &a, double &b, double &r2
}
+template<typename X>
+X absdiff(X a, X b)
+{
+ return a < b ? b - a : a - b;
+}
+
//
// ResultTable::lmsint
//
@@ -909,7 +915,7 @@ void ResultTable::lmsint(double &a, double &b, double
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- residuals[l] = abs(partialmins[i] -
+ residuals[l] = abs((long)partialmins[i] -
+ residuals[l] = absdiff(partialmins[i],
((currentslope *
column2size(i) /
slopescale) +
@@ -930,7 +930,7 @@ void ResultTable::lmsint(double &a, double &b, double
@@ -930,7 +936,7 @@ void ResultTable::lmsint(double &a, double &b, double
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- ys[l] = abs(partialmins[i] - mediany);
+ ys[l] = abs((long)partialmins[i] - mediany);
+ ys[l] = absdiff(partialmins[i], mediany);
l++;
}
}