[pango] Cast enum to int before doing calculation
- From: Ting-Wei Lan <lantw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Cast enum to int before doing calculation
- Date: Tue, 18 Jul 2017 14:59:35 +0000 (UTC)
commit a3325f632fdb7e993397385bd21c3700d5ec066e
Author: Ting-Wei Lan <lantw src gnome org>
Date: Mon Jun 5 21:25:12 2017 +0800
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
pango/fonts.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/pango/fonts.c b/pango/fonts.c
index da1940f..887f03c 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]