aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordivinity76 <[email protected]>2024-01-29 12:01:58 +0100
committerJack O'Connor <[email protected]>2024-02-04 13:31:55 -0800
commit2918c51bc693bd8608e04c790e1fccfabeb40514 (patch)
tree71eb37c0100ebe641ba6fb3dafa80b8b362c3a73
parenta65fcf63eec58b355f972f35e2e4b4e956a5d011 (diff)
silenc gcc Werror=logical-op
``` /home/travis/build/php/php-src/ext/hash/blake3/upstream_blake3/c/blake3.c: In function ‘compress_subtree_to_parent_node’: /home/travis/build/php/php-src/ext/hash/blake3/upstream_blake3/c/blake3.c:354:22: error: logical ‘and’ of mutually exclusive tests is always false [-Werror=logical-op] 354 | while (num_cvs > 2 && num_cvs <= MAX_SIMD_DEGREE_OR_2) { | ^~ cc1: all warnings being treated as errors make: *** [Makefile:1910: ext/hash/blake3/upstream_blake3/c/blake3.lo] Error 1 ``` Fixes https://github.com/BLAKE3-team/BLAKE3/issues/379. Closes https://github.com/BLAKE3-team/BLAKE3/pull/380.
-rw-r--r--c/blake3.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/c/blake3.c b/c/blake3.c
index 692f4b0..e87193c 100644
--- a/c/blake3.c
+++ b/c/blake3.c
@@ -341,21 +341,22 @@ INLINE void compress_subtree_to_parent_node(
size_t num_cvs = blake3_compress_subtree_wide(input, input_len, key,
chunk_counter, flags, cv_array);
assert(num_cvs <= MAX_SIMD_DEGREE_OR_2);
-
- // If MAX_SIMD_DEGREE is greater than 2 and there's enough input,
- // compress_subtree_wide() returns more than 2 chaining values. Condense
- // them into 2 by forming parent nodes repeatedly.
- uint8_t out_array[MAX_SIMD_DEGREE_OR_2 * BLAKE3_OUT_LEN / 2];
- // The second half of this loop condition is always true, and we just
+ // This condition is always true, and we just
// asserted it above. But GCC can't tell that it's always true, and if NDEBUG
// is set on platforms where MAX_SIMD_DEGREE_OR_2 == 2, GCC emits spurious
// warnings here. GCC 8.5 is particularly sensitive, so if you're changing
// this code, test it against that version.
- while (num_cvs > 2 && num_cvs <= MAX_SIMD_DEGREE_OR_2) {
+#if MAX_SIMD_DEGREE_OR_2 > 2
+ // If MAX_SIMD_DEGREE_OR_2 is greater than 2 and there's enough input,
+ // compress_subtree_wide() returns more than 2 chaining values. Condense
+ // them into 2 by forming parent nodes repeatedly.
+ uint8_t out_array[MAX_SIMD_DEGREE_OR_2 * BLAKE3_OUT_LEN / 2];
+ while (num_cvs > 2) {
num_cvs =
compress_parents_parallel(cv_array, num_cvs, key, flags, out_array);
memcpy(cv_array, out_array, num_cvs * BLAKE3_OUT_LEN);
}
+#endif
memcpy(out, cv_array, 2 * BLAKE3_OUT_LEN);
}