From 96299d70edba60e5eb88a1efca384bc82392d977 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 12 Oct 2021 10:42:43 -0400 Subject: [PATCH] Fix Wbitwise-instead-of-logical warnings `a || b` only evaluates b if a is false. `a | b` always evaluates both a and b. If a and b are of type bool, || is usually what you want, so clang now warns on `|` where both arguments are of type bool. This warning fires twice in harfbuzz. In both cases, `|` is used intentionally, with a comment explaining this. Slightly reorder the code a bit to make the compiler happy, and to make it obvious even without a comment that both calls should be evaluated. No intended behavior change. --- src/hb-ot-layout-gpos-table.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 1e53920f8..ac8f6eaf8 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1220,9 +1220,9 @@ struct PairSet record_size); if (record) { - /* Note the intentional use of "|" instead of short-circuit "||". */ - if (valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos()) | - valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos])) + bool applied_first = valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos()); + bool applied_second = valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]); + if (applied_first || applied_second) buffer->unsafe_to_break (buffer->idx, pos + 1); if (len2) pos++; @@ -1560,9 +1560,9 @@ struct PairPosFormat2 if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false); const Value *v = &values[record_len * (klass1 * class2Count + klass2)]; - /* Note the intentional use of "|" instead of short-circuit "||". */ - if (valueFormat1.apply_value (c, this, v, buffer->cur_pos()) | - valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx])) + bool applied_first = valueFormat1.apply_value (c, this, v, buffer->cur_pos()); + bool applied_second = valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]); + if (applied_first || applied_second) buffer->unsafe_to_break (buffer->idx, skippy_iter.idx + 1); buffer->idx = skippy_iter.idx;