diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 7e846161d545531b1ba33d828c0268a8b712598c..d22e8809ee4c6fc616da6e3e6bf2a39e0dcf214b 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -321,7 +321,7 @@ hb_bsearch_r (const void *key, const void *base, int min = 0, max = (int) nmemb - 1; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; const void *p = (const void *) (((const char *) base) + (mid * size)); int c = compar (key, p, arg); if (c < 0) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 2b1b432bad1fedf3ba71caa60b7faa3d8f252f3a..8b7ea0939a4c908cb335f8d1ee99b8b25ebada17 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -702,7 +702,7 @@ struct SortedArrayOf : ArrayOf int min = 0, max = (int) this->len - 1; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; int c = arr[mid].cmp (x); if (c < 0) max = mid - 1; @@ -825,7 +825,7 @@ struct VarSizedBinSearchArrayOf int min = 0, max = (int) header.nUnits - 1; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size)); int c = p->cmp (key); if (c < 0) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index e5793c387ea522fa39d4a466ca9b7abe78bee770..9978d1b02156a30bae1f205e12b2091884241cf2 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -249,7 +249,7 @@ struct CmapSubtableFormat4 unsigned int i; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; if (codepoint < startCount[mid]) max = mid - 1; else if (codepoint > endCount[mid]) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index dad6c4ea93fcd9aa5e3a0add400a6ed78d546709..dd4e62792856b426108093ba9b2a57de40b67f40 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -663,7 +663,7 @@ struct PairSet int min = 0, max = (int) count - 1; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; const PairValueRecord *record = &StructAtOffset (&firstPairValueRecord, record_size * mid); hb_codepoint_t mid_x = record->secondGlyph; if (x < mid_x) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 766e5fb8e61d21a58c6e68dddc9de291ea70ae53..eed4507ffce8f118605a052b1a2291dbea94fa5a 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -232,7 +232,7 @@ struct hb_vector_t const Type *array = this->arrayZ(); while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; int c = array[mid].cmp (&x); if (c < 0) max = mid - 1;