From owner-freebsd-current@freebsd.org Tue Jan 12 18:56:29 2021 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CA3B4E2FFC for ; Tue, 12 Jan 2021 18:56:29 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DFfth2n2vz4WfJ; Tue, 12 Jan 2021 18:56:28 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id A72502605BA; Tue, 12 Jan 2021 19:56:26 +0100 (CET) Subject: Re: Panic after updating To: Ian Lepore , Jakob Alvermark , FreeBSD Current References: <87512669-f0b9-eb2f-1103-170a29384ea8@alvermark.net> <34a9dafd-9690-1b33-abf8-017ad31cf2ab@alvermark.net> <60e4db60-c816-463e-0e08-a33c674ad4da@alvermark.net> <75784796-b513-5573-abc4-8c445d03c007@selasky.org> <5724744d-7710-4c3c-416b-01314cb196d4@selasky.org> <1bab5b76-eb56-671f-d52d-db1812c9be22@alvermark.net> <7fee78a371dad15e1a7b66eecfa5190e510d930f.camel@freebsd.org> From: Hans Petter Selasky Message-ID: <63efc8ee-cd5b-bf99-bcdd-a49a62c48a63@selasky.org> Date: Tue, 12 Jan 2021 19:56:17 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7fee78a371dad15e1a7b66eecfa5190e510d930f.camel@freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4DFfth2n2vz4WfJ X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.30 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net:c]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[selasky.org]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a01:4f8:c17:6c4b::2:from]; SPAMHAUS_ZRD(0.00)[2a01:4f8:c17:6c4b::2:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 18:56:29 -0000 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