From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EFE934889F for ; Tue, 20 Jan 2026 08:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768899559; cv=none; b=LQPx3VoFZ7WIZMooQ9X5zfWF3ZtVibPcqFt7KMOjv6jEgwseD4Oyv/WV6D6c7NnE/pu4oknoRfsAUXbi6tjiokx67k8IXKxLlcJKpuYsStE4xbXuLUy8KMC9f5ZFcWWNJ7bEi5+DJ8DCADsV/8JXUHByy1z4xD/9tIsx0BaF8Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768899559; c=relaxed/simple; bh=sMdRSvoG+LSVpXw+Rc3meOm0dLuxbQwv4p4D05xn+yg=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=hd0O74i7JPiFM8Y/fiGsHq7Oc1wDXwt6iNIgpSI9GlodRQyncbiCRCwo/xA9o5tmia14bhcVXO6sxDthJe/6NHLWovNOV0x5EuE3GVaDUD4vgUFJYfO04VG4MlaKv9NiHy8Xmub2+nz9/OYNCe7nC84x3opmk1LKFuKaHdZzz3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fjivNP15; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=XmwuXuV/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fjivNP15"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="XmwuXuV/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768899556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=6iFMtHhoL3bOSCrpSbQA5IrtnTyZJVqCZfgJ4obY6M4=; b=fjivNP15pcpI3YPSlbIxwzMyCZGtOXV2pCsfXlqaqF18zLoaDpCxTLcA6xgRXsHJsSzw2v 0c/GABqBnCCL1xtBPF9EOEx5rfAED6MmGcp1SSSI8u7x8fzJ6cq0edFAjz4MDB8RPyjGQt BRWChqlVaHqTdIIKwBD/qcW1YQROFTQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-400-A6hfp0Q2Mvqda1qYw851Yg-1; Tue, 20 Jan 2026 03:59:15 -0500 X-MC-Unique: A6hfp0Q2Mvqda1qYw851Yg-1 X-Mimecast-MFC-AGG-ID: A6hfp0Q2Mvqda1qYw851Yg_1768899554 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4801e9e7159so21033005e9.1 for ; Tue, 20 Jan 2026 00:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768899554; x=1769504354; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=6iFMtHhoL3bOSCrpSbQA5IrtnTyZJVqCZfgJ4obY6M4=; b=XmwuXuV/8lLMSDd7bLLokFf3uDPOnDtxppxpMDBrTG007SzsD57Sh7AltOz8cP/cHE bVL+y7ubJqHNanpdAboiebWs58HQjWs25s1lQqAltIW4Zdkg1nfaIR+fmCpvF61ndWkg IOmA4cdMRQtJHrf6Oc+k9YbNPs0M/mms5Q1ToMArNYBIZJuOx9H2ZA4PzlquqW1n3LIn 01P0fPoKaYoXTRThOiDDCLu6iXl1zDhiSTwv2faLytAcf6lC5sJUVtZinAVA16S1lWMD gkqtmSUAT2A5j+SVH8tYLjm5II53jTto+iplpQxbngE23hvvvHSg77YHdcuPpMuPlkFK NDqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768899554; x=1769504354; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6iFMtHhoL3bOSCrpSbQA5IrtnTyZJVqCZfgJ4obY6M4=; b=ND1/GGBIWmIc/UfpBv4hAiIgdVVMBDZ3GWsG03Pgz6xXDDIrT4ITjGPmYmvQ55DJd1 ZmftxUUJ5PNGxqzKQpMKvpVXu0iyQSjtyI9IFr1FYEOHhEKaJ5THLhcI8byYLSnaz2fx mSce6uVDw6RTTlr+J0QW7VcICV5GQidsnMzSLL8wECv4mo/60zkC6syc/EK1bYJM7w6l qx6T81b90ULgy4AED8F437lojZavbkJkP8EVJtCCjbjMNgGeS2NiemK21qtpP3/dTiub tYygfga59PsSSochKrMNfIdHIv6VVfbZM9gPLlut6zsckZrgB9bAwiE2Y1dIz/vuDCW5 Tnxg== X-Forwarded-Encrypted: i=1; AJvYcCVvVZxpkFQeC3brAlKrOcnu5/l4XHxYQX3rQT4X6RMNv5Iym9DAFsSirsCNTzvKnMY1GmYYlNCYh7ELKT8=@vger.kernel.org X-Gm-Message-State: AOJu0YxhJPEvUEU9ylv7/0h7DbphXdQHnygG70H4vW9WgjgTxMwCgfMu U+Z9ht7o29EgPW8oBAHqmGwkcgdlaND/DjblgzqUMqo0FH86u4nWm1ZvhLtUMNmNNKyKhTqZMao CcGK50QxNDiGIR9ylA7cAzT07+BzhLJBovnb9eyRugt/LcV7DoZ1YvFDm+q5p5iaKIQ== X-Gm-Gg: AY/fxX6gAWOTKhtjGX7ZzUbJHQM9yM4MbUky72HK7Ca/KMDtGhpkw7uBaffQiI0nfip s85OKoHr1JD960VsdBcXYuLsN2007Nx/LjtYRWpUMV20AOES/QN5LP9/m3eZAw9I9sV3ni3ExR6 XbppVKJ0KOafU484IC9vxSro9reAVzI8+o5P5DbKxSNnHtcRHzMD0ftN6Oj6TYQtCliX+uwuBrQ bdEVJkaaBcoTwmGktAZdD56S7I0ytvSTqmgjqa4CMeZYwwpdQRMdi/YJYeWPcAAedeyuZQifoFa lEhbVliP0TXAwCU1qx7vHkUliSF77Ahfv13BhnIvq4JsTn7iinWcBwSCDwznBg62aw1NqRrMpXh PKcdKsUY8G1KyMQaOVg7a2RI3uRcvRibcVhJpmpZNz4wHBiEWTi6h7gJ1k5t6TUh1QC04Hz35is HCTLHiKNO4 X-Received: by 2002:a05:600c:528c:b0:47e:e61d:b8d2 with SMTP id 5b1f17b1804b1-4803e7f18d4mr13837415e9.27.1768899554035; Tue, 20 Jan 2026 00:59:14 -0800 (PST) X-Received: by 2002:a05:600c:528c:b0:47e:e61d:b8d2 with SMTP id 5b1f17b1804b1-4803e7f18d4mr13837165e9.27.1768899553635; Tue, 20 Jan 2026 00:59:13 -0800 (PST) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (185-132-178-103.hosted-by-worldstream.net. [185.132.178.103]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47f4b2755absm365703365e9.15.2026.01.20.00.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 00:59:13 -0800 (PST) Message-ID: Subject: Re: [PATCH 17/26] rv/rvgen: fix possibly unbound variable in ltl2k From: Gabriele Monaco To: Wander Lairson Costa Cc: Steven Rostedt , Nam Cao , open list , "open list:RUNTIME VERIFICATION (RV)" Date: Tue, 20 Jan 2026 09:59:11 +0100 In-Reply-To: <20260119205601.105821-18-wander@redhat.com> References: <20260119205601.105821-1-wander@redhat.com> <20260119205601.105821-18-wander@redhat.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0BrZXJuZWwub3JnPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmjKX2MCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfIQuAD+JulczTN6l7oJjyroySU55Fbjdvo52xiYYlMjPG7dCTsBAMFI7dSL5zg98I+8 cXY1J7kyNsY6/dcipqBM4RMaxXsOtCRHYWJyaWVsZSBNb25hY28gPGdtb25hY29AcmVkaGF0LmNvb T6InAQTFgoARAIbAwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgBYhBMrKEfgLgd0WcK eo9u9KbElYeE3yBQJoymCyAhkBAAoJEO9KbElYeE3yjX4BAJ/ETNnlHn8OjZPT77xGmal9kbT1bC1 7DfrYVISWV2Y1AP9HdAMhWNAvtCtN2S1beYjNybuK6IzWYcFfeOV+OBWRDQ== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-01-19 at 17:45 -0300, Wander Lairson Costa wrote: > Initialize loop variable `i` before the for loop in abbreviate_atoms > function to fix pyright static type checker error. The previous code > left `i` potentially unbound in edge cases where the range could be > empty, though this would not occur in practice since the loop always > executes at least once with the given range parameters. >=20 > The initialization to zero ensures that `i` has a defined value before > entering the loop scope, satisfying static analysis requirements > while preserving the existing logic. The for loop immediately assigns > i to the first value from the range, so the initialization value is > never actually used in normal execution paths. >=20 > This change resolves the pyright reportPossiblyUnbound error without > altering the function's behavior or performance characteristics. So are we just pleasing the tool or is there a real implication of this? Apparently code like for i in range(len([]), -1, -1): pass print(i) works just fine since range() returns at least 0 (as you mentioned in the c= ommit message) and i is not used before assignation in the loop, so I don't reall= y see a problem. Apparently pyright devs don't want ([1]) to implement a logic to sort out t= he /possibly/ unbound error here. >From what I understand, this code is already not pythonic, so rather than silence the warning to please this tool I'd just refactor the code not to u= se i after the loop (or leave it as it is, since it works fine). What do you think? Thanks, Gabriele [1] - https://github.com/microsoft/pyright/issues/844 >=20 > Signed-off-by: Wander Lairson Costa > --- > =C2=A0tools/verification/rvgen/rvgen/ltl2k.py | 1 + > =C2=A01 file changed, 1 insertion(+) >=20 > diff --git a/tools/verification/rvgen/rvgen/ltl2k.py > b/tools/verification/rvgen/rvgen/ltl2k.py > index fa9ea6d597095..94dc64af1716d 100644 > --- a/tools/verification/rvgen/rvgen/ltl2k.py > +++ b/tools/verification/rvgen/rvgen/ltl2k.py > @@ -45,6 +45,7 @@ def abbreviate_atoms(atoms: list[str]) -> list[str]: > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0 abbrs =3D [] > =C2=A0=C2=A0=C2=A0=C2=A0 for atom in atoms: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D 0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for i in range(len(atom)= , -1, -1): > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = if sum(a.startswith(atom[:i]) for a in atoms) > 1: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 break