2011-04-03 Paul Eggert <eggert@cs.ucla.edu>
* font.c (font_find_for_lface, Ffont_get_glyphs): Remove unused vars.
+ (font_score): Avoid potential overflow in diff calculation.
* fns.c (substring_both): Remove var that is set but not used.
(sxhash): Redo loop for clarity and to avoid wraparound warning.
for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++)
if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]))
{
- int diff = (XINT (AREF (entity, i)) >> 8) - (XINT (spec_prop[i]) >> 8);
-
+ EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8)
+ - (XINT (spec_prop[i]) >> 8));
if (diff < 0)
diff = - diff;
- if (diff > 0)
- score |= min (diff, 127) << sort_shift_bits[i];
+ score |= min (diff, 127) << sort_shift_bits[i];
}
/* Score the size. Maximum difference is 127. */