[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] util/cutils: Silent Coverity array overrun warning in freq_t
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH] util/cutils: Silent Coverity array overrun warning in freq_to_str() |
Date: |
Thu, 29 Oct 2020 16:40:13 -0400 |
On Thu, Oct 29, 2020 at 07:16:35PM +0000, Peter Maydell wrote:
> On Thu, 29 Oct 2020 at 19:13, Peter Maydell <peter.maydell@linaro.org> wrote:
> > We should either consistently assume that idx can never
> > get to 7 (ie don't check it in the while loop condition
> > because that test can never return true) or we should
> > consistently guard against it happening (by switching the
> > while loop to "<=", or by handling the idx==ARRAY_SIZE(suffixes)
> > case specially.)
>
> Oops; "switching to <=" isn't the right thing; you'd need to switch
> to "< ARRAY_SIZE(suffixes) - 1". Anyway I think we should
> do the other of the two options, not this one.
"< ARRAY_SIZE(suffixes) - 1" patch submitted at
20201029203850.434351-1-ehabkost@redhat.com/">https://lore.kernel.org/qemu-devel/20201029203850.434351-1-ehabkost@redhat.com/
--
Eduardo