From: Aleksandr Lyapunov <alyapunov@tarantool.org> To: Kirill Yukhin <kyukhin@tarantool.org>, avtikhon@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH] test: fix local array access in heap_iterator unit test Date: Fri, 4 Dec 2020 09:33:20 +0300 [thread overview] Message-ID: <7bae6a08-1931-3616-4429-4685ea18737a@tarantool.org> (raw) In-Reply-To: <86d41c348ae271f5a8a8dec6fdd4ccc045a0408d.1607006062.git.kyukhin@tarantool.org> Hello! Thanks for the patch, see my comment below: On 03.12.2020 17:38, Kirill Yukhin wrote: > Index variable run from 1 to 5 and was used to index > array of size 4. Use iv - 1 instead. > > Discovered by Coverity. > --- > > Issue: N/A > Branch: https://github.com/tarantool/tarantool/tree/kyukhin/fix-heap_iterator > CI: https://gitlab.com/tarantool/tarantool/-/pipelines/224811793 > > test/unit/heap_iterator.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/test/unit/heap_iterator.c b/test/unit/heap_iterator.c > index 4fde39d..3fcefff 100644 > --- a/test/unit/heap_iterator.c > +++ b/test/unit/heap_iterator.c > @@ -111,15 +111,15 @@ test_iterator_small() > if (val < 1 || val > 5) Accessing below by [val - 1] is ok, but the main problem is that this check is wrong. If the heap works correctly - 'val' must be in range [1..4]. I think we should fix to "val < 1 || val > 4". After that both variants of accessing array by [val] and [val - 1] would be ok. > fail("from iterator returned incorrect value", > "val < 1 || val > 5"); > - if (used_key[val]) > + if (used_key[val - 1]) > fail("from iterator some value returned twice", > "used[val]"); > - used_key[val] = 1; > + used_key[val - 1] = 1; > } > > bool f = true; > for (uint32_t i = 1; i < 5; ++i) > - f = used_key[i] && f; > + f = used_key[i - 1] && f; > if (!f) > fail("some node was skipped", "!f"); >
next prev parent reply other threads:[~2020-12-04 6:33 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-03 14:38 Kirill Yukhin 2020-12-04 6:33 ` Aleksandr Lyapunov [this message] 2020-12-04 8:54 ` Kirill Yukhin 2020-12-07 12:24 ` Aleksandr Lyapunov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=7bae6a08-1931-3616-4429-4685ea18737a@tarantool.org \ --to=alyapunov@tarantool.org \ --cc=avtikhon@tarantool.org \ --cc=kyukhin@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] test: fix local array access in heap_iterator unit test' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox