Re: Panic after updating

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Tue, 12 Jan 2021 19:56:17 +0100
On 1/12/21 7:45 PM, Ian Lepore wrote:
>>> -       for (int i = 0; i <= sc->sc_npins; i++) {
>>> +       for (int i = 0; i != sc->sc_npins; i++) {
>>>                  mtx_destroy(&sc->sc_pin_intr[i].mtx);
>>>                  free(&sc->sc_pin_intr[i].pin, M_GPIOC);
>>>          }
>> --HPS
>>
> If that is the problem, I'd rather see it fixed by using the idiomatic
> i < sc->sc_npins rather than the non-standard != test.  (But I don't
> feel strongly enough about it to learn how to use git and commit the
> fix myself.)

Hi Ian,

I think it is more serious that the iteration variable is declared 
inside the for-loop :-)

At least it is pretty obvious that the array written is one element too 
small. I've always used != instead of <= in for-loops. But if there is a 
certain style in there, I'm good with < too, though I've always seen < 
as an overhead compared to != , because to implement < you need a 
subtraction, while != is just a comparison ...

--HPS
Received on Tue Jan 12 2021 - 17:56:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:26 UTC