fix control flow

`do { ...; continue; } while(0)` doesn't retry the loop body.

pointed out by Coverity Scan and mame.
This commit is contained in:
Koichi Sasada 2024-11-30 04:13:04 +09:00
parent a6d673a284
commit 8e6fd8fed4
Notes: git 2026-07-01 20:19:35 +00:00

6
hash.c
View File

@ -712,7 +712,7 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
RUBY_ASSERT(rb_gc_obj_slot_size(hash) >= sizeof(struct RHash) + sizeof(ar_table));
// prepare hash values
do {
while (1) {
st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];
bound = RHASH_AR_TABLE_BOUND(hash);
size = RHASH_AR_TABLE_SIZE(hash);
@ -727,7 +727,9 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash);
if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue;
if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue;
} while (0);
break;
}
// make st
st_table tab;