Panic after updating

Hans Petter Selasky hps at selasky.org
Tue Jan 12 18:56:29 UTC 2021


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


More information about the freebsd-current mailing list