From nobody Mon Nov 29 15:14:37 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 20DCF18AE1D3 for ; Mon, 29 Nov 2021 15:14:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ua1-x92a.google.com (mail-ua1-x92a.google.com [IPv6:2607:f8b0:4864:20::92a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J2pmn2gQlz4dfF for ; Mon, 29 Nov 2021 15:14:49 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-ua1-x92a.google.com with SMTP id t13so34735578uad.9 for ; Mon, 29 Nov 2021 07:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S8n9hxn8USssC32kefVVFL18dF1a71HGklFq1en7Wec=; b=0j40FmkT42HsX38ofr0aWYrab+6IZIz9TbYMhU/U9gFtBsr6vYxkQEcV8foa85u0cR AitUg1gPTapG/FMnW0wya4ZKWbTzHKYDRYQgcXk7wTpsbhlnCL7oA6syEGeUJXDfDOn5 ZeiMGMRMsaFkv8IZaQmOvlw6IlK3PqTejjC8Od0v2f6Pv6x4rRy2NHLhNRoI7DJ6Zo8m 7WKkCFWJKqQEcc0/DQBFRqXQuYNI4c2qI02Gvfjxd2qL+Q4iKRMUd3/ufF00Tn9l02Sa WgdT8kGu8tGgmUtKnthpRTYb7dvzXt8nCqGo+kn0OYxjU9elVNcWOxzj/kcUTjVTJCIp d1hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S8n9hxn8USssC32kefVVFL18dF1a71HGklFq1en7Wec=; b=5G2gagSOYHpcSsvtVAl/N1/4XN3zDPFAw941BUJSh94LLJYVzI9KLmYpb2QxAGZ97u lzlTegWm0VDvU+HBByi3GPwvLJvGLNbym478TYKJIcdaQzR07WayF0Ft1a9d8ERadEyS EZg5krtbrv+PZQO0+EAz/cKw34dh5PxjdfGQ2PWvXJPOxhBDMpbFHmK6D7V4EqiwnzkY aMd7a/8d8L1YDWbjMbB67Eu0VAQ5ldAK1/wwx+emeHVOxrJqCT1EFuyySCqOBaPRsqzq qkKsmf6UGJ5z2hGNG83OpKZP92a6SlJh+b4af3uJtZnKgv5Pne6+wNgU9bcG9ufg8gyl J8lQ== X-Gm-Message-State: AOAM533UoS05uKjC9LEbxkVtGCzjIJA/7VV0kpHfr89F7IMFDUAfOy08 o32V98/uIioc1EPOqpjkAs/M5Z4X2GI0nqtcOuSC9nYE0HDwVLCI X-Google-Smtp-Source: ABdhPJz5XvE0C1+1oJDfty2iDc8CZlAAtLbtyu6V8cUMK/EjXgc1cIqs9fQObPzrycsmWO8kcQEIKEE9ZKOfpHUYH5w= X-Received: by 2002:a67:f912:: with SMTP id t18mr33736028vsq.6.1638198883406; Mon, 29 Nov 2021 07:14:43 -0800 (PST) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202111051525.1A5FPgwj073325@gitrepo.freebsd.org> In-Reply-To: From: Warner Losh Date: Mon, 29 Nov 2021 08:14:37 -0700 Message-ID: Subject: Re: git: d836c48e7110 - main - cam_periph: wired is really a bool, update it to a bool. To: Mateusz Guzik Cc: Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000846aab05d1eee668" X-Rspamd-Queue-Id: 4J2pmn2gQlz4dfF X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --000000000000846aab05d1eee668 Content-Type: text/plain; charset="UTF-8" On Mon, Nov 29, 2021 at 6:21 AM Mateusz Guzik wrote: > On 11/5/21, Warner Losh wrote: > > The branch main has been updated by imp: > > > > URL: > > > https://cgit.FreeBSD.org/src/commit/?id=d836c48e7110f2894885cf84ce8990f7916663cc > > > > commit d836c48e7110f2894885cf84ce8990f7916663cc > > Author: Warner Losh > > AuthorDate: 2021-11-05 14:56:48 +0000 > > Commit: Warner Losh > > CommitDate: 2021-11-05 14:56:48 +0000 > > > > cam_periph: wired is really a bool, update it to a bool. > > > > Sponsored by: Netflix > > Reviewed by: scottl > > Differential Revision: https://reviews.freebsd.org/D32823 > > --- > > sys/cam/cam_periph.c | 25 +++++++++++++------------ > > 1 file changed, 13 insertions(+), 12 deletions(-) > > > > diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c > > index bb4baaf0888f..54fe9a0ef40c 100644 > > --- a/sys/cam/cam_periph.c > > +++ b/sys/cam/cam_periph.c > > > @@ -600,8 +600,9 @@ static u_int > > camperiphunit(struct periph_driver *p_drv, path_id_t pathid, > > target_id_t target, lun_id_t lun, const char *sn) > > { > > + bool wired; > > u_int unit; > > - int wired, i, val, dunit; > > + int i, val, dunit; > > const char *dname, *strval; > > char pathbuf[32], *periph_name; > > > > @@ -610,29 +611,29 @@ camperiphunit(struct periph_driver *p_drv, > path_id_t > > pathid, > > unit = 0; > > i = 0; > > dname = periph_name; > > - for (wired = 0; resource_find_dev(&i, dname, &dunit, NULL, NULL) > == 0; > > - wired = 0) { > > + while (resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0) { > > + wired = false; > > This has a side effect of no longer initializing wired if the first > resource_find_dev call returns != 0, which in turn causes KMSAN to > panic due to: > > unit = camperiphnextunit(p_drv, unit, wired, pathid, target, lun); > > below. > > It is unclear to me what this code should do. Plopping 'wired = > false;' upfront at least restores the previous state and prevents the > panic. > https://reviews.freebsd.org/D33163 I made this change at the last minute due to a review comment to change this to a while loop. wired should always be false unless we find something to the contrary. Plus, the old code did that as well. Taken together, the change is obvious. I never saw it on my systems because all of them wire units in different ways. > > if (resource_string_value(dname, dunit, "at", &strval) == > 0) { > > if (strcmp(strval, pathbuf) != 0) > > continue; > > - wired++; > > + wired = true; > > } > > if (resource_int_value(dname, dunit, "target", &val) == 0) > { > > if (val != target) > > continue; > > - wired++; > > + wired = true; > > } > > if (resource_int_value(dname, dunit, "lun", &val) == 0) { > > if (val != lun) > > continue; > > - wired++; > > + wired = true; > > } > > if (resource_string_value(dname, dunit, "sn", &strval) == > 0) { > > if (sn == NULL || strcmp(strval, sn) != 0) > > continue; > > - wired++; > > + wired = true; > > } > > - if (wired != 0) { > > + if (wired) { > > unit = dunit; > > break; > > } > > > > > -- > Mateusz Guzik > --000000000000846aab05d1eee668--