aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-rw-r--r--FICS/ratings.c12
-rw-r--r--FICS/ratings.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/FICS/ratings.c b/FICS/ratings.c
index 8fd683c..5f06ccc 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -1304,6 +1304,18 @@ com_statistics(int p, param_list param)
return COM_OK;
}
+/*
+ * Return the difference of 'a - b'
+ */
+PUBLIC int
+int_diff(const char *fn, const int a, const int b)
+{
+ if ((b > 0 && a < INT_MIN + b) ||
+ (b < 0 && a > INT_MAX + b))
+ errx(1, "%s: integer overflow (%d - %d)", fn, a, b);
+ return (a - b);
+}
+
PUBLIC int
com_fixrank(int p, param_list param)
{
diff --git a/FICS/ratings.h b/FICS/ratings.h
index 4cf47a8..5461cd4 100644
--- a/FICS/ratings.h
+++ b/FICS/ratings.h
@@ -61,6 +61,7 @@ extern int com_hbest(int, param_list);
extern int com_hrank(int, param_list);
extern int com_rank(int, param_list);
extern int com_statistics(int, param_list);
+extern int int_diff(const char *, const int, const int);
extern int is_active(int);
extern int rating_delta(int, int, int, int, int);
extern int rating_update(int);