summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw@src.gnome.org>2017-06-05 21:25:12 +0800
committerTing-Wei Lan <lantw@src.gnome.org>2017-07-18 22:54:58 +0800
commita3325f632fdb7e993397385bd21c3700d5ec066e (patch)
treeed1e8c5eebdb4193ff6e719b79934ea8360444ac /pango/fonts.c
parent7a8744e17fdb8ebb975301813665736667900634 (diff)
downloadpango-a3325f632fdb7e993397385bd21c3700d5ec066e.tar.gz
Cast enum to int before doing calculation
It seems that it is possible for compilers to use unsigned interger types to store enum values, so we should cast them to signed interger types before doing calculation to avoid getting unexpected results. https://bugzilla.gnome.org/show_bug.cgi?id=783428
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index da1940f2..887f03cb 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -613,14 +613,14 @@ compute_distance (const PangoFontDescription *a,
{
if (a->style == b->style)
{
- return abs(a->weight - b->weight);
+ return abs((int)(a->weight) - (int)(b->weight));
}
else if (a->style != PANGO_STYLE_NORMAL &&
b->style != PANGO_STYLE_NORMAL)
{
/* Equate oblique and italic, but with a big penalty
*/
- return 1000000 + abs (a->weight - b->weight);
+ return 1000000 + abs ((int)(a->weight) - (int)(b->weight));
}
else
return G_MAXINT;