From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 21EE641323E for ; Wed, 4 Feb 2026 14:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216608; cv=none; b=Q0cXTIrf6ChnESz8RisVsTidntlzR6F3doPQnxJ4O0GAj0nT1gHNBBXqv6THdg4LyA4f8Bq3NVF41CbOnk9Tq9k2+LUXg4s43L4GbrRXI35ukTSG/J3YUVUrJLaAd9zGZ9ZXGw8xx4yhd9jP157NUv2EIp7nwmFcbzztTG6wWsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216608; c=relaxed/simple; bh=X2kf3fZ5LR5TgJP+TJj6XwWzQKodGD7lX1MkZwTSo2o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o9qc7CCooUPHoyByRJPp5m0a9Xeqf/p5O187cgM8IeJ4pqGmKbb2hp2JTFckqCoRYe4QOUhkxYK+AGX+iXt5XYSviC6+JjdWRgGrsMHoB56drNz48NR63VvOeJC9e50gltZrxCQpIze91MOSr4Z6EqobVC4tRfQXnp4fiUp9ZyA= 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=JNp4WLsn; arc=none smtp.client-ip=170.10.129.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="JNp4WLsn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LdDoCJaPfE+4alVDcmgH28uP/ZjHFVm7qqMaWa15mmE=; b=JNp4WLsncmip8gJFcuSIi9CNELTxRXTNpdbOSB5OVLnQnZpQMWyjytnBg5OiFIwX07ntM3 wV0KezHgwZF5J2aVD2TUyA8a1HUZzT/q5h2eLl2Ne4r/+9sBcqGC1WlHJ9bGci6e5R+mpq D8v9KaZhIugeNajcX5JUTuIn627F16I= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-THbIqvTdMveM9GC8GLT2NQ-1; Wed, 04 Feb 2026 09:50:04 -0500 X-MC-Unique: THbIqvTdMveM9GC8GLT2NQ-1 X-Mimecast-MFC-AGG-ID: THbIqvTdMveM9GC8GLT2NQ_1770216603 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D18971956095; Wed, 4 Feb 2026 14:50:02 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 28B5130001B9; Wed, 4 Feb 2026 14:49:59 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 01/20] rv/rvgen: introduce AutomataError exception class Date: Wed, 4 Feb 2026 11:42:27 -0300 Message-ID: <20260204144914.104028-2-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Replace the generic except Exception block with a custom AutomataError class that inherits from Exception. This provides more precise exception handling for automata parsing and validation errors while avoiding overly broad exception catches that could mask programming errors like SyntaxError or TypeError. The AutomataError class is raised when DOT file processing fails due to invalid format, I/O errors, or malformed automaton definitions. The main entry point catches this specific exception and provides a user-friendly error message to stderr before exiting. Signed-off-by: Wander Lairson Costa --- tools/verification/rvgen/__main__.py | 9 ++++++--- tools/verification/rvgen/rvgen/automata.py | 17 ++++++++++++----- tools/verification/rvgen/rvgen/dot2c.py | 4 ++-- tools/verification/rvgen/rvgen/generator.py | 7 ++----- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvge= n/__main__.py index fa6fc1f4de2f7..3bd438f8476ed 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -8,11 +8,15 @@ # For further information, see: # Documentation/trace/rv/da_monitor_synthesis.rst =20 +from sys import stderr + + if __name__ =3D=3D '__main__': from rvgen.dot2k import dot2k from rvgen.generator import Monitor from rvgen.container import Container from rvgen.ltl2k import ltl2k + from rvgen.automata import AutomataError import argparse import sys =20 @@ -51,9 +55,8 @@ if __name__ =3D=3D '__main__': sys.exit(1) else: monitor =3D Container(vars(params)) - except Exception as e: - print('Error: '+ str(e)) - print("Sorry : :-(") + except AutomataError as e: + print(f"There was an error processing {params.spec}: {e}", file=3D= sys.stderr) sys.exit(1) =20 print("Writing the monitor into the directory %s" % monitor.name) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 3f06aef8d4fdc..6ecd5ccd8f3d3 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -10,6 +10,13 @@ =20 import ntpath =20 +class AutomataError(Exception): + """Exception raised for errors in automata parsing and validation. + + Raised when DOT file processing fails due to invalid format, I/O error= s, + or malformed automaton definitions. + """ + class Automata: """Automata class: Reads a dot file and part it as an automata. =20 @@ -32,11 +39,11 @@ class Automata: basename =3D ntpath.basename(self.__dot_path) if not basename.endswith(".dot") and not basename.endswith(".gv"): print("not a dot file") - raise Exception("not a dot file: %s" % self.__dot_path) + raise AutomataError("not a dot file: %s" % self.__dot_path) =20 model_name =3D ntpath.splitext(basename)[0] if model_name.__len__() =3D=3D 0: - raise Exception("not a dot file: %s" % self.__dot_path) + raise AutomataError("not a dot file: %s" % self.__dot_path) =20 return model_name =20 @@ -45,8 +52,8 @@ class Automata: dot_lines =3D [] try: dot_file =3D open(self.__dot_path) - except: - raise Exception("Cannot open the file: %s" % self.__dot_path) + except OSError as exc: + raise AutomataError(f"Cannot open the file: {self.__dot_path}"= ) from exc =20 dot_lines =3D dot_file.read().splitlines() dot_file.close() @@ -55,7 +62,7 @@ class Automata: line =3D dot_lines[cursor].split() =20 if (line[0] !=3D "digraph") and (line[1] !=3D "state_automaton"): - raise Exception("Not a valid .dot format: %s" % self.__dot_pat= h) + raise AutomataError("Not a valid .dot format: %s" % self.__dot= _path) else: cursor +=3D 1 return dot_lines diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index 06a26bf15a7e9..74147ae2942f9 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -13,7 +13,7 @@ # For further information, see: # Documentation/trace/rv/deterministic_automata.rst =20 -from .automata import Automata +from .automata import Automata, AutomataError =20 class Dot2c(Automata): enum_suffix =3D "" @@ -71,7 +71,7 @@ class Dot2c(Automata): min_type =3D "unsigned int" =20 if self.states.__len__() > 1000000: - raise Exception("Too many states: %d" % self.states.__len__()) + raise AutomataError("Too many states: %d" % self.states.__len_= _()) =20 return min_type =20 diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index 3441385c11770..a7bee6b1ea70c 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -51,10 +51,7 @@ class RVGenerator: raise FileNotFoundError("Could not find the rv directory, do you h= ave the kernel source installed?") =20 def _read_file(self, path): - try: - fd =3D open(path, 'r') - except OSError: - raise Exception("Cannot open the file: %s" % path) + fd =3D open(path, 'r') =20 content =3D fd.read() =20 @@ -65,7 +62,7 @@ class RVGenerator: try: path =3D os.path.join(self.abs_template_dir, file) return self._read_file(path) - except Exception: + except OSError: # Specific template file not found. Try the generic template f= ile in the template/ # directory, which is one level up path =3D os.path.join(self.abs_template_dir, "..", file) --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EC1451E520C for ; Wed, 4 Feb 2026 14:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216629; cv=none; b=d8sEuOIwcQtqz2uFyk+9cdR8yvut5OT2WKPAEnpjsZ/Fx9oC0xXXrtBX1fC6VjW6quYhwojJZOPWkvb+yo+zQUBB12+UjuqY+f8r8pMqeGzgitoIghLEgNycH4xBeBmbB8Wuj6s+35FqvfXSQBlS4ost33V3JvNKxL5pNE+Bzgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216629; c=relaxed/simple; bh=fs1Eb/BwH26KDZ/aWSModwgBQ1nMC3ZPEInp7b+m5+U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xwi61JwPNptv31bZDxpNuccepkj4qtEtizoGFmdpH0QKKNl/HrwAFyBffR8vH/sWrFLeVvZ+xaI47R3SEIkT1KG4WqfVWJjK73NYj/SMuDeCDTiI95X2+X6NaG61WHyywADEFsKUT2aLb8bWxB7/aPWH8rszYqCPipFY6Y+qsgw= 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=LhduDMjB; arc=none smtp.client-ip=170.10.129.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="LhduDMjB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ucfd3QhmcEvG5vsY6IAEUx/lDH1JMpNbncoTgo/FLFE=; b=LhduDMjB8FMb6GZOE2sOUAqCCAYk1+IrPdUb9bDIQ+cK0fftaKo9VxF9mUGVLakI7HPm/c nUn2NSWieZ1EkceYCGW1g0ZToTRGaSaAI8PZ/uGb0UWLqJhlYIdueglVlCX0uAGwvyoeMr pONwjCPC1SGUPAbu42leVjkH/KjJgXQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-Mo4rgb_FNiaGyf2-2vwAaQ-1; Wed, 04 Feb 2026 09:50:24 -0500 X-MC-Unique: Mo4rgb_FNiaGyf2-2vwAaQ-1 X-Mimecast-MFC-AGG-ID: Mo4rgb_FNiaGyf2-2vwAaQ_1770216623 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 76E93180025F; Wed, 4 Feb 2026 14:50:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8F8530001BF; Wed, 4 Feb 2026 14:50:20 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 02/20] rv/rvgen: remove bare except clauses in generator Date: Wed, 4 Feb 2026 11:42:28 -0300 Message-ID: <20260204144914.104028-3-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Remove bare except clauses from the generator module that were catching all exceptions including KeyboardInterrupt and SystemExit. This follows the same exception handling improvements made in the previous AutomataError commit and addresses PEP 8 violations. The bare except clause in __create_directory was silently catching and ignoring all errors after printing a message, which could mask serious issues. For __write_file, the bare except created a critical bug where the file variable could remain undefined if open() failed, causing a NameError when attempting to write to or close the file. These methods now let OSError propagate naturally, allowing callers to handle file system errors appropriately. This provides clearer error reporting and allows Python's exception handling to show complete stack traces with proper error types and locations. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/generator.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index a7bee6b1ea70c..af1662e2c20a7 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -198,17 +198,10 @@ obj-$(CONFIG_RV_MON_%s) +=3D monitors/%s/%s.o os.mkdir(path) except FileExistsError: return - except: - print("Fail creating the output dir: %s" % self.name) =20 def __write_file(self, file_name, content): - try: - file =3D open(file_name, 'w') - except: - print("Fail writing to file: %s" % file_name) - + file =3D open(file_name, 'w') file.write(content) - file.close() =20 def _create_file(self, file_name, content): --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 067AB27B359 for ; Wed, 4 Feb 2026 14:50:49 +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=1770216650; cv=none; b=JvBfy/s8xqh+6kKZ8bATKDNaaShLypgjDkD1nuhGMSGBOTE6vNet5fMgcOG0rFHlZ1CUYkLKP344yLvlkCnLAjY5VjbUK8D00nuI65i64YD7rtkbotCgHqeN8hgUTFoM3gzhC8o2iaF2xHuBCd6A4WCB3FGm6fNlrMiwkurs2T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216650; c=relaxed/simple; bh=uw8Y/gbtGzmHziJ8wr+w4OLcZuLRi9VsR1jG7zXONPA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VvXLHZdDnTR8qNGbQSAQDK3tULdbp+ezd0xacmJNYP3HgvwoyMOf+zYVc14sQUE9usbOnzJhgyX1tqGD7H5qOQxW9DjCxA5/c9WtB6zuh6ip39Z3k0n7nggageobmh6O5x512J1e7vtV2I7FVTTSRGoSB1FHr3lhPLFUZgeCZQI= 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=SRfqrxvI; 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="SRfqrxvI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZVsNyoC557q7cMHp/lOqcuEfRZUDL3yQPrSVpzREeQ=; b=SRfqrxvIa4iigxwRGc8s1o9WlyWC8ywL4dClQR5EmqR11SKBAoeVBqUgzQbRqx7DUM1mUC F4F7/mcFhFhtYxKPtdyIjKX31bNCzQ59gl/kmtAYAA0YzLxLe5GSVb3aGpTh/ALxJ06KTc BOoyMeTC5zNZkXokEUp7Y8aXknX4Iw8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-ZQGjqqUZNn6EqascA82WAQ-1; Wed, 04 Feb 2026 09:50:45 -0500 X-MC-Unique: ZQGjqqUZNn6EqascA82WAQ-1 X-Mimecast-MFC-AGG-ID: ZQGjqqUZNn6EqascA82WAQ_1770216644 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC8261956095; Wed, 4 Feb 2026 14:50:44 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E25C730001A5; Wed, 4 Feb 2026 14:50:41 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 03/20] rv/rvgen: replace % string formatting with f-strings Date: Wed, 4 Feb 2026 11:42:29 -0300 Message-ID: <20260204144914.104028-4-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Replace all instances of percent-style string formatting with f-strings across the rvgen codebase. This modernizes the string formatting to use Python 3.6+ features, providing clearer and more maintainable code while improving runtime performance. The conversion handles all formatting cases including simple variable substitution, multi-variable formatting, and complex format specifiers. Dynamic width formatting is converted from "%*s" to "{var:>{width}}" using proper alignment syntax. Template strings for generated C code properly escape braces using double-brace syntax to produce literal braces in the output. F-strings provide approximately 2x performance improvement over percent formatting and are the recommended approach in modern Python. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/__main__.py | 6 +-- tools/verification/rvgen/rvgen/automata.py | 6 +-- tools/verification/rvgen/rvgen/dot2c.py | 38 ++++++------- tools/verification/rvgen/rvgen/dot2k.py | 26 ++++----- tools/verification/rvgen/rvgen/generator.py | 59 ++++++++++----------- tools/verification/rvgen/rvgen/ltl2k.py | 30 +++++------ 6 files changed, 81 insertions(+), 84 deletions(-) diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvge= n/__main__.py index 3bd438f8476ed..50b7d4227fb16 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -45,7 +45,7 @@ if __name__ =3D=3D '__main__': =20 try: if params.subcmd =3D=3D "monitor": - print("Opening and parsing the specification file %s" % params= .spec) + print(f"Opening and parsing the specification file {params.spe= c}") if params.monitor_class =3D=3D "da": monitor =3D dot2k(params.spec, params.monitor_type, vars(p= arams)) elif params.monitor_class =3D=3D "ltl": @@ -59,11 +59,11 @@ if __name__ =3D=3D '__main__': print(f"There was an error processing {params.spec}: {e}", file=3D= sys.stderr) sys.exit(1) =20 - print("Writing the monitor into the directory %s" % monitor.name) + print(f"Writing the monitor into the directory {monitor.name}") monitor.print_files() print("Almost done, checklist") if params.subcmd =3D=3D "monitor": - print(" - Edit the %s/%s.c to add the instrumentation" % (monitor= .name, monitor.name)) + print(f" - Edit the {monitor.name}/{monitor.name}.c to add the in= strumentation") print(monitor.fill_tracepoint_tooltip()) print(monitor.fill_makefile_tooltip()) print(monitor.fill_kconfig_tooltip()) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 6ecd5ccd8f3d3..bd8c04526be3a 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -39,11 +39,11 @@ class Automata: basename =3D ntpath.basename(self.__dot_path) if not basename.endswith(".dot") and not basename.endswith(".gv"): print("not a dot file") - raise AutomataError("not a dot file: %s" % self.__dot_path) + raise AutomataError(f"not a dot file: {self.__dot_path}") =20 model_name =3D ntpath.splitext(basename)[0] if model_name.__len__() =3D=3D 0: - raise AutomataError("not a dot file: %s" % self.__dot_path) + raise AutomataError(f"not a dot file: {self.__dot_path}") =20 return model_name =20 @@ -62,7 +62,7 @@ class Automata: line =3D dot_lines[cursor].split() =20 if (line[0] !=3D "digraph") and (line[1] !=3D "state_automaton"): - raise AutomataError("Not a valid .dot format: %s" % self.__dot= _path) + raise AutomataError(f"Not a valid .dot format: {self.__dot_pat= h}") else: cursor +=3D 1 return dot_lines diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index 74147ae2942f9..6a2ad4fbf7824 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -28,17 +28,17 @@ class Dot2c(Automata): =20 def __get_enum_states_content(self) -> list[str]: buff =3D [] - buff.append("\t%s%s," % (self.initial_state, self.enum_suffix)) + buff.append(f"\t{self.initial_state}{self.enum_suffix},") for state in self.states: if state !=3D self.initial_state: - buff.append("\t%s%s," % (state, self.enum_suffix)) - buff.append("\tstate_max%s," % (self.enum_suffix)) + buff.append(f"\t{state}{self.enum_suffix},") + buff.append(f"\tstate_max{self.enum_suffix},") =20 return buff =20 def format_states_enum(self) -> list[str]: buff =3D [] - buff.append("enum %s {" % self.enum_states_def) + buff.append(f"enum {self.enum_states_def} {{") buff +=3D self.__get_enum_states_content() buff.append("};\n") =20 @@ -47,15 +47,15 @@ class Dot2c(Automata): def __get_enum_events_content(self) -> list[str]: buff =3D [] for event in self.events: - buff.append("\t%s%s," % (event, self.enum_suffix)) + buff.append(f"\t{event}{self.enum_suffix},") =20 - buff.append("\tevent_max%s," % self.enum_suffix) + buff.append(f"\tevent_max{self.enum_suffix},") =20 return buff =20 def format_events_enum(self) -> list[str]: buff =3D [] - buff.append("enum %s {" % self.enum_events_def) + buff.append(f"enum {self.enum_events_def} {{") buff +=3D self.__get_enum_events_content() buff.append("};\n") =20 @@ -71,25 +71,25 @@ class Dot2c(Automata): min_type =3D "unsigned int" =20 if self.states.__len__() > 1000000: - raise AutomataError("Too many states: %d" % self.states.__len_= _()) + raise AutomataError(f"Too many states: {self.states.__len__()}= ") =20 return min_type =20 def format_automaton_definition(self) -> list[str]: min_type =3D self.get_minimun_type() buff =3D [] - buff.append("struct %s {" % self.struct_automaton_def) - buff.append("\tchar *state_names[state_max%s];" % (self.enum_suffi= x)) - buff.append("\tchar *event_names[event_max%s];" % (self.enum_suffi= x)) - buff.append("\t%s function[state_max%s][event_max%s];" % (min_type= , self.enum_suffix, self.enum_suffix)) - buff.append("\t%s initial_state;" % min_type) - buff.append("\tbool final_states[state_max%s];" % (self.enum_suffi= x)) + buff.append(f"struct {self.struct_automaton_def} {{") + buff.append(f"\tchar *state_names[state_max{self.enum_suffix}];") + buff.append(f"\tchar *event_names[event_max{self.enum_suffix}];") + buff.append(f"\t{min_type} function[state_max{self.enum_suffix}][e= vent_max{self.enum_suffix}];") + buff.append(f"\t{min_type} initial_state;") + buff.append(f"\tbool final_states[state_max{self.enum_suffix}];") buff.append("};\n") return buff =20 def format_aut_init_header(self) -> list[str]: buff =3D [] - buff.append("static const struct %s %s =3D {" % (self.struct_autom= aton_def, self.var_automaton_def)) + buff.append(f"static const struct {self.struct_automaton_def} {sel= f.var_automaton_def} =3D {{") return buff =20 def __get_string_vector_per_line_content(self, entries: list[str]) -> = str: @@ -134,9 +134,9 @@ class Dot2c(Automata): next_state =3D self.function[x][y] + self.enum_suffix =20 if linetoolong: - line +=3D "\t\t\t%s" % next_state + line +=3D f"\t\t\t{next_state}" else: - line +=3D "%*s" % (maxlen, next_state) + line +=3D f"{next_state:>{maxlen}}" if y !=3D nr_events-1: line +=3D ",\n" if linetoolong else ", " else: @@ -180,7 +180,7 @@ class Dot2c(Automata): =20 def format_aut_init_final_states(self) -> list[str]: buff =3D [] - buff.append("\t.final_states =3D { %s }," % self.get_aut_init_final= _states()) + buff.append(f"\t.final_states =3D {{ {self.get_aut_init_final_state= s()} }},") =20 return buff =20 @@ -196,7 +196,7 @@ class Dot2c(Automata): =20 def format_invalid_state(self) -> list[str]: buff =3D [] - buff.append("#define %s state_max%s\n" % (self.invalid_state_str, = self.enum_suffix)) + buff.append(f"#define {self.invalid_state_str} state_max{self.enum= _suffix}\n") =20 return buff =20 diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index 6128fe2384308..6d4151acc9fe3 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -19,7 +19,7 @@ class dot2k(Monitor, Dot2c): self.monitor_type =3D MonitorType Monitor.__init__(self, extra_params) Dot2c.__init__(self, file_path, extra_params.get("model_name")) - self.enum_suffix =3D "_%s" % self.name + self.enum_suffix =3D f"_{self.name}" =20 def fill_monitor_type(self) -> str: return self.monitor_type.upper() @@ -27,7 +27,7 @@ class dot2k(Monitor, Dot2c): def fill_tracepoint_handlers_skel(self) -> str: buff =3D [] for event in self.events: - buff.append("static void handle_%s(void *data, /* XXX: fill he= ader */)" % event) + buff.append(f"static void handle_{event}(void *data, /* XXX: f= ill header */)") buff.append("{") handle =3D "handle_event" if self.is_start_event(event): @@ -38,9 +38,9 @@ class dot2k(Monitor, Dot2c): handle =3D "handle_start_run_event" if self.monitor_type =3D=3D "per_task": buff.append("\tstruct task_struct *p =3D /* XXX: how do I = get p? */;"); - buff.append("\tda_%s(p, %s%s);" % (handle, event, self.enu= m_suffix)); + buff.append(f"\tda_{handle}(p, {event}{self.enum_suffix});= "); else: - buff.append("\tda_%s(%s%s);" % (handle, event, self.enum_s= uffix)); + buff.append(f"\tda_{handle}({event}{self.enum_suffix});"); buff.append("}") buff.append("") return '\n'.join(buff) @@ -48,20 +48,20 @@ class dot2k(Monitor, Dot2c): def fill_tracepoint_attach_probe(self) -> str: buff =3D [] for event in self.events: - buff.append("\trv_attach_trace_probe(\"%s\", /* XXX: tracepoin= t */, handle_%s);" % (self.name, event)) + buff.append(f"\trv_attach_trace_probe(\"{self.name}\", /* XXX:= tracepoint */, handle_{event});") return '\n'.join(buff) =20 def fill_tracepoint_detach_helper(self) -> str: buff =3D [] for event in self.events: - buff.append("\trv_detach_trace_probe(\"%s\", /* XXX: tracepoin= t */, handle_%s);" % (self.name, event)) + buff.append(f"\trv_detach_trace_probe(\"{self.name}\", /* XXX:= tracepoint */, handle_{event});") return '\n'.join(buff) =20 def fill_model_h_header(self) -> list[str]: buff =3D [] buff.append("/* SPDX-License-Identifier: GPL-2.0 */") buff.append("/*") - buff.append(" * Automatically generated C representation of %s aut= omaton" % (self.name)) + buff.append(f" * Automatically generated C representation of {self= .name} automaton") buff.append(" * For further information about this format, see ker= nel documentation:") buff.append(" * Documentation/trace/rv/deterministic_automata.rs= t") buff.append(" */") @@ -75,10 +75,10 @@ class dot2k(Monitor, Dot2c): # # Adjust the definition names # - self.enum_states_def =3D "states_%s" % self.name - self.enum_events_def =3D "events_%s" % self.name - self.struct_automaton_def =3D "automaton_%s" % self.name - self.var_automaton_def =3D "automaton_%s" % self.name + self.enum_states_def =3D f"states_{self.name}" + self.enum_events_def =3D f"events_{self.name}" + self.struct_automaton_def =3D f"automaton_{self.name}" + self.var_automaton_def =3D f"automaton_{self.name}" =20 buff =3D self.fill_model_h_header() buff +=3D self.format_model() @@ -113,8 +113,8 @@ class dot2k(Monitor, Dot2c): tp_args.insert(0, tp_args_id) tp_proto_c =3D ", ".join([a+b for a,b in tp_args]) tp_args_c =3D ", ".join([b for a,b in tp_args]) - buff.append(" TP_PROTO(%s)," % tp_proto_c) - buff.append(" TP_ARGS(%s)" % tp_args_c) + buff.append(f" TP_PROTO({tp_proto_c}),") + buff.append(f" TP_ARGS({tp_args_c})") return '\n'.join(buff) =20 def fill_main_c(self) -> str: diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index af1662e2c20a7..6d16fb68798a7 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -40,7 +40,7 @@ class RVGenerator: if platform.system() !=3D "Linux": raise OSError("I can only run on Linux.") =20 - kernel_path =3D os.path.join("/lib/modules/%s/build" % platform.re= lease(), self.rv_dir) + kernel_path =3D os.path.join(f"/lib/modules/{platform.release()}/b= uild", self.rv_dir) =20 # if the current kernel is from a distro this may not be a full ke= rnel tree # verify that one of the files we are going to modify is available @@ -69,11 +69,11 @@ class RVGenerator: return self._read_file(path) =20 def fill_parent(self): - return "&rv_%s" % self.parent if self.parent else "NULL" + return f"&rv_{self.parent}" if self.parent else "NULL" =20 def fill_include_parent(self): if self.parent: - return "#include \n" % (self.parent, self.pa= rent) + return f"#include \n" return "" =20 def fill_tracepoint_handlers_skel(self): @@ -119,7 +119,7 @@ class RVGenerator: buff =3D [] buff.append(" # XXX: add dependencies if there") if self.parent: - buff.append(" depends on RV_MON_%s" % self.parent.upper()) + buff.append(f" depends on RV_MON_{self.parent.upper()}") buff.append(" default y") return '\n'.join(buff) =20 @@ -145,31 +145,30 @@ class RVGenerator: monitor_class_type =3D self.fill_monitor_class_type() if self.auto_patch: self._patch_file("rv_trace.h", - "// Add new monitors based on CONFIG_%s here" = % monitor_class_type, - "#include " % (self.na= me, self.name)) - return " - Patching %s/rv_trace.h, double check the result" %= self.rv_dir + f"// Add new monitors based on CONFIG_{monitor= _class_type} here", + f"#include ") + return f" - Patching {self.rv_dir}/rv_trace.h, double check t= he result" =20 - return """ - Edit %s/rv_trace.h: -Add this line where other tracepoints are included and %s is defined: -#include -""" % (self.rv_dir, monitor_class_type, self.name, self.name) + return f""" - Edit {self.rv_dir}/rv_trace.h: +Add this line where other tracepoints are included and {monitor_class_type= } is defined: +#include +""" =20 def _kconfig_marker(self, container=3DNone) -> str: - return "# Add new %smonitors here" % (container + " " - if container else "") + return f"# Add new {container + ' ' if container else ''}monitors = here" =20 def fill_kconfig_tooltip(self): if self.auto_patch: # monitors with a container should stay together in the Kconfig self._patch_file("Kconfig", self._kconfig_marker(self.parent), - "source \"kernel/trace/rv/monitors/%s/Kconfig\= "" % (self.name)) - return " - Patching %s/Kconfig, double check the result" % se= lf.rv_dir + f"source \"kernel/trace/rv/monitors/{self.name= }/Kconfig\"") + return f" - Patching {self.rv_dir}/Kconfig, double check the = result" =20 - return """ - Edit %s/Kconfig: + return f""" - Edit {self.rv_dir}/Kconfig: Add this line where other monitors are included: -source \"kernel/trace/rv/monitors/%s/Kconfig\" -""" % (self.rv_dir, self.name) +source \"kernel/trace/rv/monitors/{self.name}/Kconfig\" +""" =20 def fill_makefile_tooltip(self): name =3D self.name @@ -177,18 +176,18 @@ source \"kernel/trace/rv/monitors/%s/Kconfig\" if self.auto_patch: self._patch_file("Makefile", "# Add new monitors here", - "obj-$(CONFIG_RV_MON_%s) +=3D monitors/%s/%s.o= " % (name_up, name, name)) - return " - Patching %s/Makefile, double check the result" % s= elf.rv_dir + f"obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors= /{name}/{name}.o") + return f" - Patching {self.rv_dir}/Makefile, double check the= result" =20 - return """ - Edit %s/Makefile: + return f""" - Edit {self.rv_dir}/Makefile: Add this line where other monitors are included: -obj-$(CONFIG_RV_MON_%s) +=3D monitors/%s/%s.o -""" % (self.rv_dir, name_up, name, name) +obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors/{name}/{name}.o +""" =20 def fill_monitor_tooltip(self): if self.auto_patch: - return " - Monitor created in %s/monitors/%s" % (self.rv_dir,= self. name) - return " - Move %s/ to the kernel's monitor directory (%s/monitor= s)" % (self.name, self.rv_dir) + return f" - Monitor created in {self.rv_dir}/monitors/{self.n= ame}" + return f" - Move {self.name}/ to the kernel's monitor directory (= {self.rv_dir}/monitors)" =20 def __create_directory(self): path =3D self.name @@ -205,13 +204,13 @@ obj-$(CONFIG_RV_MON_%s) +=3D monitors/%s/%s.o file.close() =20 def _create_file(self, file_name, content): - path =3D "%s/%s" % (self.name, file_name) + path =3D f"{self.name}/{file_name}" if self.auto_patch: path =3D os.path.join(self.rv_dir, "monitors", path) self.__write_file(path, content) =20 def __get_main_name(self): - path =3D "%s/%s" % (self.name, "main.c") + path =3D f"{self.name}/main.c" if not os.path.exists(path): return "main.c" return "__main.c" @@ -221,11 +220,11 @@ obj-$(CONFIG_RV_MON_%s) +=3D monitors/%s/%s.o =20 self.__create_directory() =20 - path =3D "%s.c" % self.name + path =3D f"{self.name}.c" self._create_file(path, main_c) =20 model_h =3D self.fill_model_h() - path =3D "%s.h" % self.name + path =3D f"{self.name}.h" self._create_file(path, model_h) =20 kconfig =3D self.fill_kconfig() @@ -256,5 +255,5 @@ class Monitor(RVGenerator): def print_files(self): super().print_files() trace_h =3D self.fill_trace_h() - path =3D "%s_trace.h" % self.name + path =3D f"{self.name}_trace.h" self._create_file(path, trace_h) diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index b075f98d50c47..fa9ea6d597095 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -73,7 +73,7 @@ class ltl2k(generator.Monitor): ] =20 for node in self.ba: - buf.append("\tS%i," % node.id) + buf.append(f"\tS{node.id},") buf.append("\tRV_NUM_BA_STATES") buf.append("};") buf.append("static_assert(RV_NUM_BA_STATES <=3D RV_MAX_BA_STATES);= ") @@ -82,7 +82,7 @@ class ltl2k(generator.Monitor): def _fill_atoms(self): buf =3D ["enum ltl_atom {"] for a in sorted(self.atoms): - buf.append("\tLTL_%s," % a) + buf.append(f"\tLTL_{a},") buf.append("\tLTL_NUM_ATOM") buf.append("};") buf.append("static_assert(LTL_NUM_ATOM <=3D RV_MAX_LTL_ATOM);") @@ -96,7 +96,7 @@ class ltl2k(generator.Monitor): ] =20 for name in self.atoms_abbr: - buf.append("\t\t\"%s\"," % name) + buf.append(f"\t\t\"{name}\",") =20 buf.extend([ "\t};", @@ -113,19 +113,19 @@ class ltl2k(generator.Monitor): continue =20 if isinstance(node.op, ltl2ba.AndOp): - buf.append("\tbool %s =3D %s && %s;" % (node, node.op.left= , node.op.right)) + buf.append(f"\tbool {node} =3D {node.op.left} && {node.op.= right};") required_values |=3D {str(node.op.left), str(node.op.right= )} elif isinstance(node.op, ltl2ba.OrOp): - buf.append("\tbool %s =3D %s || %s;" % (node, node.op.left= , node.op.right)) + buf.append(f"\tbool {node} =3D {node.op.left} || {node.op.= right};") required_values |=3D {str(node.op.left), str(node.op.right= )} elif isinstance(node.op, ltl2ba.NotOp): - buf.append("\tbool %s =3D !%s;" % (node, node.op.child)) + buf.append(f"\tbool {node} =3D !{node.op.child};") required_values.add(str(node.op.child)) =20 for atom in self.atoms: if atom.lower() not in required_values: continue - buf.append("\tbool %s =3D test_bit(LTL_%s, mon->atoms);" % (at= om.lower(), atom)) + buf.append(f"\tbool {atom.lower()} =3D test_bit(LTL_{atom}, mo= n->atoms);") =20 buf.reverse() =20 @@ -153,7 +153,7 @@ class ltl2k(generator.Monitor): ]) =20 for node in self.ba: - buf.append("\tcase S%i:" % node.id) + buf.append(f"\tcase S{node.id}:") =20 for o in sorted(node.outgoing): line =3D "\t\tif " @@ -163,7 +163,7 @@ class ltl2k(generator.Monitor): lines =3D break_long_line(line, indent) buf.extend(lines) =20 - buf.append("\t\t\t__set_bit(S%i, next);" % o.id) + buf.append(f"\t\t\t__set_bit(S{o.id}, next);") buf.append("\t\tbreak;") buf.extend([ "\t}", @@ -197,7 +197,7 @@ class ltl2k(generator.Monitor): lines =3D break_long_line(line, indent) buf.extend(lines) =20 - buf.append("\t\t__set_bit(S%i, mon->states);" % node.id) + buf.append(f"\t\t__set_bit(S{node.id}, mon->states);") buf.append("}") return buf =20 @@ -205,23 +205,21 @@ class ltl2k(generator.Monitor): buff =3D [] buff.append("static void handle_example_event(void *data, /* XXX: = fill header */)") buff.append("{") - buff.append("\tltl_atom_update(task, LTL_%s, true/false);" % self.= atoms[0]) + buff.append(f"\tltl_atom_update(task, LTL_{self.atoms[0]}, true/fa= lse);") buff.append("}") buff.append("") return '\n'.join(buff) =20 def fill_tracepoint_attach_probe(self): - return "\trv_attach_trace_probe(\"%s\", /* XXX: tracepoint */, han= dle_example_event);" \ - % self.name + return f"\trv_attach_trace_probe(\"{self.name}\", /* XXX: tracepoi= nt */, handle_example_event);" =20 def fill_tracepoint_detach_helper(self): - return "\trv_detach_trace_probe(\"%s\", /* XXX: tracepoint */, han= dle_sample_event);" \ - % self.name + return f"\trv_detach_trace_probe(\"{self.name}\", /* XXX: tracepoi= nt */, handle_sample_event);" =20 def fill_atoms_init(self): buff =3D [] for a in self.atoms: - buff.append("\tltl_atom_set(mon, LTL_%s, true/false);" % a) + buff.append(f"\tltl_atom_set(mon, LTL_{a}, true/false);") return '\n'.join(buff) =20 def fill_model_h(self): --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 3E684281530 for ; Wed, 4 Feb 2026 14:51:11 +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=1770216671; cv=none; b=arkTTDbhLgYrQkUHtUWT4zLY9LeZMAn3RS9/W24eK38fumHB/23ROVXzbWAyPakyWHJpg8v1f5eoxnfZughjXSuvRhgpV6C4mCgDl28vGARFOSq3uwc4DLNWKb5CsPqbVP4SaFX7rgLYlh58bQ1PX6iWaKAmnd3snx6OmDJmEgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216671; c=relaxed/simple; bh=9c4O8Mdm+ewS4xkU8uOqSlYRYgEjTA8B0nGZ//Zuabc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rzd6HJLgu/AoHhjeAPZOOVGbUt3sMQYzOUp9uEWWmyQzffAdIhCn4Vj9uwiWBxEXhmZSNKL+thRD107gwV5ItCU7wOf79UwpG19b2pYh7+7LAfGdq0TGnJ/YK5t1OnzrjgTWlm6Q1ev6VBhv54aOM/l9qUDFxm/qg7uT1cN2Sjk= 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=K/dw+TaO; 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="K/dw+TaO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8sJU2RJB3KUNxhCCTIsG7NiQCqE4cV2jotMaoDK+oRk=; b=K/dw+TaO11MePuTX6y5QnLY3WUv/bqdhaCrgJ4LFbUzW2hhdbA/TEf2HPLqQJrb2HTxzLD hDyTMSTL+EXDCG4O2yJGplKMaMTEqnr7/F6YeOkK7SuvMt1bVXVf8ekD0+FgbtVtd31jW1 BvMwV6/zjKmiU5TOLO7fvEhrKPShQoE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-6akKEpkxPhusFHdnBJFHrw-1; Wed, 04 Feb 2026 09:51:06 -0500 X-MC-Unique: 6akKEpkxPhusFHdnBJFHrw-1 X-Mimecast-MFC-AGG-ID: 6akKEpkxPhusFHdnBJFHrw_1770216665 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F8BC1956094; Wed, 4 Feb 2026 14:51:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C193A30001BC; Wed, 4 Feb 2026 14:51:02 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 04/20] rv/rvgen: replace __len__() calls with len() Date: Wed, 4 Feb 2026 11:42:30 -0300 Message-ID: <20260204144914.104028-5-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Replace all direct calls to the __len__() dunder method with the idiomatic len() built-in function across the rvgen codebase. This change eliminates a Python anti-pattern where dunder methods are called directly instead of using their corresponding built-in functions. The changes affect nine instances across two files. In automata.py, the empty string check is further improved by using truthiness testing instead of explicit length comparison. In dot2c.py, all length checks in the get_minimun_type, __get_max_strlen_of_states, and get_aut_init_function methods now use the standard len() function. Additionally, spacing around keyword arguments has been corrected to follow PEP 8 guidelines. Direct calls to dunder methods like __len__() are discouraged in Python because they bypass the language's abstraction layer and reduce code readability. Using len() provides the same functionality while adhering to Python community standards and making the code more familiar to Python developers. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/automata.py | 2 +- tools/verification/rvgen/rvgen/dot2c.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index bd8c04526be3a..07ae81e9a49fa 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -42,7 +42,7 @@ class Automata: raise AutomataError(f"not a dot file: {self.__dot_path}") =20 model_name =3D ntpath.splitext(basename)[0] - if model_name.__len__() =3D=3D 0: + if not model_name: raise AutomataError(f"not a dot file: {self.__dot_path}") =20 return model_name diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index 6a2ad4fbf7824..b3a49779d4cc5 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -64,14 +64,14 @@ class Dot2c(Automata): def get_minimun_type(self) -> str: min_type =3D "unsigned char" =20 - if self.states.__len__() > 255: + if len(self.states) > 255: min_type =3D "unsigned short" =20 - if self.states.__len__() > 65535: + if len(self.states) > 65535: min_type =3D "unsigned int" =20 - if self.states.__len__() > 1000000: - raise AutomataError(f"Too many states: {self.states.__len__()}= ") + if len(self.states) > 1000000: + raise AutomataError(f"Too many states: {len(self.states)}") =20 return min_type =20 @@ -114,12 +114,12 @@ class Dot2c(Automata): return buff =20 def __get_max_strlen_of_states(self) -> int: - max_state_name =3D max(self.states, key =3D len).__len__() - return max(max_state_name, self.invalid_state_str.__len__()) + max_state_name =3D len(max(self.states, key=3Dlen)) + return max(max_state_name, len(self.invalid_state_str)) =20 def get_aut_init_function(self) -> str: - nr_states =3D self.states.__len__() - nr_events =3D self.events.__len__() + nr_states =3D len(self.states) + nr_events =3D len(self.events) buff =3D [] =20 maxlen =3D self.__get_max_strlen_of_states() + len(self.enum_suffi= x) --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 3C85627B359 for ; Wed, 4 Feb 2026 14:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216691; cv=none; b=umgffJu39s5kwbzR4hMoAHcRC1gDgb5T5l+4qgnfEHQjS2t9T7mcWLPl+s05BaBzNeX0NbAMuOV+nv3R1uhqvsrfbQzARgh3ruxupR/d0bxoTekRJ2CM9CHKWUkhSZMi0CSgsq4KjemGM8v7gkl7hJ6A6bPAt53JYQfWBtsJHwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216691; c=relaxed/simple; bh=x7f/QArb6Yd58zFMtFyowo0pjz38ig88AIQ7PNG9Fgg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bklkP7nt1dQFDZt+Ff9zsORpAYlZcnPY36JTzos+CE4ktLeupzdyTqHvhehPjIFT7SlT/9W2dJgSPisTHeBgCATXG6AiKC6t9rjn8s+zkPwaKpPOB1LOpN3ewjUINAnNNnLyoQnL2OwxaY2P0XrLD14xMIyonyti+0df3dz2xaE= 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=Kr/0oTu1; arc=none smtp.client-ip=170.10.129.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="Kr/0oTu1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eKJIIR4sCiicMLk+1rg/I2qnycwySEM7ioO+qJg8T1I=; b=Kr/0oTu1CCS0imZhQ2gzbKxnsTB5BsGdVYjn7i/neBX3TRy42yJTyvNXirojiTkoX7WoWN Gq0cLAUVCgKvHHz8pjdqbWuqWNZDN5MZI+XPw6+onu9YUd2U8s7xL8VcSTsL0kpOjLQplV AuEmUbM40mPJgjMfqO82dCSr4JARI6k= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-x6iJdHTnPmueyuxtwS179w-1; Wed, 04 Feb 2026 09:51:27 -0500 X-MC-Unique: x6iJdHTnPmueyuxtwS179w-1 X-Mimecast-MFC-AGG-ID: x6iJdHTnPmueyuxtwS179w_1770216686 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D90831800451; Wed, 4 Feb 2026 14:51:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 622B730001A5; Wed, 4 Feb 2026 14:51:23 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 05/20] rv/rvgen: remove unnecessary semicolons Date: Wed, 4 Feb 2026 11:42:31 -0300 Message-ID: <20260204144914.104028-6-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Remove unnecessary semicolons from Python code in the rvgen tool. Python does not require semicolons to terminate statements, and their presence goes against PEP 8 style guidelines. These semicolons were likely added out of habit from C-style languages. This cleanup improves consistency with Python coding standards and aligns with the recent improvements to remove other Python anti-patterns from the codebase. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/dot2k.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index 6d4151acc9fe3..c70a9812abbf6 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -37,10 +37,10 @@ class dot2k(Monitor, Dot2c): buff.append("\t/* XXX: validate that this event is only va= lid in the initial state */") handle =3D "handle_start_run_event" if self.monitor_type =3D=3D "per_task": - buff.append("\tstruct task_struct *p =3D /* XXX: how do I = get p? */;"); - buff.append(f"\tda_{handle}(p, {event}{self.enum_suffix});= "); + buff.append("\tstruct task_struct *p =3D /* XXX: how do I = get p? */;") + buff.append(f"\tda_{handle}(p, {event}{self.enum_suffix});= ") else: - buff.append(f"\tda_{handle}({event}{self.enum_suffix});"); + buff.append(f"\tda_{handle}({event}{self.enum_suffix});") buff.append("}") buff.append("") return '\n'.join(buff) --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 BFCDE413224 for ; Wed, 4 Feb 2026 14:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216712; cv=none; b=FJxVgwILjkLbSaKEFc2QhN8l2AtoL2CAYxPLJyQhDi/LgFp3TXT3xGdCJLuoyc5WRSpNPxHzGBmeDLmEqIbKzydI2eGPMMtDg7tx9f5bqEzUEYnLIoIuCAPOqPCyXWnwUkh8xAV6DklihSUMvdzzO/65bAgYZRo3Yya8vWxZO00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216712; c=relaxed/simple; bh=vKGoCud62RvTn/RnPIPbJSk8pA3OGV7VeKLMQKjyh+w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SLUScfH3OS3d3qXavpQea1yi6KwtQ0mjcfYLedT4GIpNFyFPcZKulJG5ZuBCcIGVzz5L0wFWk5IIJk/FOXJGDb3lIhsnpGVJVwj+S6RApCJi04Kw27Le/JWe+h50ZU31ypjTzwB4w3CQ4lBxL+wgs0Xpp67rFXPDgskVf6eSLJs= 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=Zsr7/lni; arc=none smtp.client-ip=170.10.129.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="Zsr7/lni" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=keHT6bdZvc3LtAXA8IGY3q2fOIXGt3Nvqkknb+sVMEQ=; b=Zsr7/lniluhdeZPfpdNKmjds8IUQ7TPJt6MXZwvlMslEebKjemJD8ZVngeEU+LxhUGcrL6 2q4jVNtMBi4+Hy66qP9hOnougbQsX+pOBIKEuONt458uclJHG8DpXaYseF6D71KvYmMB9Y H8JdGhUXpDiRhxfUQiXmTxOpLys8pKQ= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-scbrbT51NtWHnT0oR8H5Sw-1; Wed, 04 Feb 2026 09:51:47 -0500 X-MC-Unique: scbrbT51NtWHnT0oR8H5Sw-1 X-Mimecast-MFC-AGG-ID: scbrbT51NtWHnT0oR8H5Sw_1770216706 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B3F371956059; Wed, 4 Feb 2026 14:51:46 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3242A30001B9; Wed, 4 Feb 2026 14:51:43 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 06/20] rv/rvgen: use context managers for file operations Date: Wed, 4 Feb 2026 11:42:32 -0300 Message-ID: <20260204144914.104028-7-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Replace manual file open and close operations with context managers throughout the rvgen codebase. The previous implementation used explicit open() and close() calls, which could lead to resource leaks if exceptions occurred between opening and closing the file handles. This change affects three file operations: reading DOT specification files in the automata parser, reading template files in the generator base class, and writing generated monitor files. All now use the with statement to ensure proper resource cleanup even in error conditions. Context managers provide automatic cleanup through the with statement, which guarantees that file handles are closed when the with block exits regardless of whether an exception occurred. This follows PEP 343 recommendations and is the standard Python idiom for resource management. The change also reduces code verbosity while improving safety and maintainability. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 6 ++---- tools/verification/rvgen/rvgen/generator.py | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 07ae81e9a49fa..1feb5f0c0bc3e 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -51,13 +51,11 @@ class Automata: cursor =3D 0 dot_lines =3D [] try: - dot_file =3D open(self.__dot_path) + with open(self.__dot_path) as dot_file: + dot_lines =3D dot_file.read().splitlines() except OSError as exc: raise AutomataError(f"Cannot open the file: {self.__dot_path}"= ) from exc =20 - dot_lines =3D dot_file.read().splitlines() - dot_file.close() - # checking the first line: line =3D dot_lines[cursor].split() =20 diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index 6d16fb68798a7..ee75e111feef1 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -51,11 +51,8 @@ class RVGenerator: raise FileNotFoundError("Could not find the rv directory, do you h= ave the kernel source installed?") =20 def _read_file(self, path): - fd =3D open(path, 'r') - - content =3D fd.read() - - fd.close() + with open(path, 'r') as fd: + content =3D fd.read() return content =20 def _read_template_file(self, file): @@ -199,9 +196,8 @@ obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors/{name}/{na= me}.o return =20 def __write_file(self, file_name, content): - file =3D open(file_name, 'w') - file.write(content) - file.close() + with open(file_name, 'w') as file: + file.write(content) =20 def _create_file(self, file_name, content): path =3D f"{self.name}/{file_name}" --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 AA9B5286A4 for ; Wed, 4 Feb 2026 14:52:10 +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=1770216730; cv=none; b=YGx7+8XzQt3i5QU0VpZtjrcC5ifrhlL3wjNBH2EL5XyGSQapCAC2cdlrXc3dt+9695coke6aopWtDxAQ4ImqncbpcW3aOVZeWCK4XX63QNGRYfv+87OnfJZdCpWaRih8jIyyjwBGFfDACLpFinvvY+VyZYc5L2/yMpzxFOjtVgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216730; c=relaxed/simple; bh=IGs1ScYkFP71z6UE7aLtED39zD3lhjPE8dE990QTpiU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fuLUhv7KxpDQqRTUCBDAPTSKAuzefPV8wDTXFZPq33Qnx79Ysjej6EFavftEX5wLCrcoERJY+UcIHX/xd7fcUb95sm32+zYg9fugs+AEuASM2QDaJevrUJk5rjQ5hTJ0FDg7VDHpRY1BfLc3e12wZgeK5pVPBohN2MMWk2q0nc8= 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=Dt4hk8Du; 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="Dt4hk8Du" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P84/evlpnt3DS/S6sXWGMrp9V98TiF/ksHbNeWWrihw=; b=Dt4hk8DuIlWLPT8O/sfhqq/A4VMjaZNCC94xLE7W9hblpGf38llPB5fzkqnY4zcFTaCL9z ieiI6UYTfHvTmjZmRxi6iRQwpx2nU6PgQ4jDdVzr7rUlMZ+nwvqFUZVXHFi0K0+cAs3FeR vujuKG7uLNyhP16PJ4YWW/XlyIml3bs= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-8ReFqjsNMByCzp8K5EXM7w-1; Wed, 04 Feb 2026 09:52:08 -0500 X-MC-Unique: 8ReFqjsNMByCzp8K5EXM7w-1 X-Mimecast-MFC-AGG-ID: 8ReFqjsNMByCzp8K5EXM7w_1770216727 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5CA461956096; Wed, 4 Feb 2026 14:52:07 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CEA3F30001A5; Wed, 4 Feb 2026 14:52:04 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 07/20] rv/rvgen: fix typos in automata and generator docstring and comments Date: Wed, 4 Feb 2026 11:42:33 -0300 Message-ID: <20260204144914.104028-8-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix two typos in the Automata class documentation that have been present since the initial implementation. Fix the class docstring: "part it" instead of "parses it". Additionally, a comment describing transition labels contained the misspelling "lables" instead of "labels". Fix a typo in the comment describing the insertion of the initial state into the states list: "bein og" should be "beginning of". Fix typo in the module docstring: "Abtract" should be "Abstract". Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 6 +++--- tools/verification/rvgen/rvgen/generator.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 1feb5f0c0bc3e..0d7cbd0c634a9 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -18,7 +18,7 @@ class AutomataError(Exception): """ =20 class Automata: - """Automata class: Reads a dot file and part it as an automata. + """Automata class: Reads a dot file and parses it as an automata. =20 Attributes: dot_file: A dot file with an state_automaton definition. @@ -113,7 +113,7 @@ class Automata: states =3D sorted(set(states)) states.remove(initial_state) =20 - # Insert the initial state at the bein og the states + # Insert the initial state at the beginning of the states states.insert(0, initial_state) =20 if not has_final_states: @@ -134,7 +134,7 @@ class Automata: line =3D self.__dot_lines[cursor].split() event =3D line[-2].replace('"','') =20 - # when a transition has more than one lables, they are lik= e this + # when a transition has more than one labels, they are lik= e this # "local_irq_enable\nhw_local_irq_enable_n" # so split them. =20 diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index ee75e111feef1..a3fbb1ac74916 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -3,7 +3,7 @@ # # Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira # -# Abtract class for generating kernel runtime verification monitors from s= pecification file +# Abstract class for generating kernel runtime verification monitors from = specification file =20 import platform import os --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 64A8B41B35D for ; Wed, 4 Feb 2026 14:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216753; cv=none; b=BM0Ga1XFQzvJV1aJ5YZezD3Eev6FW7I3h6CSm6GhAKPXUflXw5xJlp0Hzmlkv3fqUmCvV/GhnXH5xQieIDBoS7hnIR4qli+sZW8wXp2Z2op6DRco61nujJBSX9mMRgaZliIdjEwVxtLfGnPIn5WYLCFmPqVFWs2sl3ZJMUjxRt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216753; c=relaxed/simple; bh=8BhQ94pNwocXkF1J4tZldasmJvF2BbjLKCc6e/4bvNw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A57DkpYtgG+g6L4rT2C0uVjvhy4oZVlLijP9F4osLeTMiL2TyKDIByTkzQPcAezGMdui/WRqqvQfQiZEIP7Dpj/Q6s7Ee0U8UDoz3qzMGR8TWEKUiP9c8YfB+4H8cI0Pq64OPanTBit93wm0+lWyqIjxJiYH9iGaAcz+5R93uI8= 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=PkUYyWpz; arc=none smtp.client-ip=170.10.129.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="PkUYyWpz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+88c6tIz2dzJRW/pA5eB0yGHhQNthhVkp195CIWpCkE=; b=PkUYyWpza1WVgUNl8fSxZMWsGRi/8vfwcgu663C4uSkIgOovrCUQlq/s7ZujJ2Wv4pFSUz LWFNiSR9TQIXeQBkHGBvPAF7lJkxbhOpoz0O6EzXCxWnA9yeb7rx0YVzUVFpXNZHKzwot9 SIiVZn2BzkbrDTJ1E24A1/Y4gzl9Uxs= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-ff8tcclGOF2TwCCfPqda6w-1; Wed, 04 Feb 2026 09:52:29 -0500 X-MC-Unique: ff8tcclGOF2TwCCfPqda6w-1 X-Mimecast-MFC-AGG-ID: ff8tcclGOF2TwCCfPqda6w_1770216748 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E4DE1956052; Wed, 4 Feb 2026 14:52:28 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BBC2D30001A5; Wed, 4 Feb 2026 14:52:25 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 08/20] rv/rvgen: fix PEP 8 whitespace violations Date: Wed, 4 Feb 2026 11:42:34 -0300 Message-ID: <20260204144914.104028-9-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix whitespace violations throughout the rvgen codebase to comply with PEP 8 style guidelines. The changes address missing whitespace after commas, around operators, and in collection literals that were flagged by pycodestyle. The fixes include adding whitespace after commas in string replace chains and function arguments, adding whitespace around arithmetic operators, removing extra whitespace in list comprehensions, and fixing dictionary literal spacing. These changes improve code readability and consistency with Python coding standards. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/automata.py | 12 ++++++------ tools/verification/rvgen/rvgen/dot2c.py | 2 +- tools/verification/rvgen/rvgen/dot2k.py | 4 ++-- tools/verification/rvgen/rvgen/generator.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 0d7cbd0c634a9..deb1f09556c3c 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -95,7 +95,7 @@ class Automata: raw_state =3D line[-1] =20 # "enabled_fired"}; -> enabled_fired - state =3D raw_state.replace('"', '').replace('};', '').replace= (',','_') + state =3D raw_state.replace('"', '').replace('};', '').replace= (',', '_') if state[0:7] =3D=3D "__init_": initial_state =3D state[7:] else: @@ -132,7 +132,7 @@ class Automata: # ------------ event is here ------------^^^^^ if self.__dot_lines[cursor].split()[1] =3D=3D "->": line =3D self.__dot_lines[cursor].split() - event =3D line[-2].replace('"','') + event =3D line[-2].replace('"', '') =20 # when a transition has more than one labels, they are lik= e this # "local_irq_enable\nhw_local_irq_enable_n" @@ -162,7 +162,7 @@ class Automata: nr_state +=3D 1 =20 # declare the matrix.... - matrix =3D [[ self.invalid_state_str for x in range(nr_event)] for= y in range(nr_state)] + matrix =3D [[self.invalid_state_str for x in range(nr_event)] for = y in range(nr_state)] =20 # and we are back! Let's fill the matrix cursor =3D self.__get_cursor_begin_events() @@ -170,9 +170,9 @@ class Automata: while self.__dot_lines[cursor].lstrip()[0] =3D=3D '"': if self.__dot_lines[cursor].split()[1] =3D=3D "->": line =3D self.__dot_lines[cursor].split() - origin_state =3D line[0].replace('"','').replace(',','_') - dest_state =3D line[2].replace('"','').replace(',','_') - possible_events =3D line[-2].replace('"','').replace("\\n"= , " ") + origin_state =3D line[0].replace('"', '').replace(',', '_') + dest_state =3D line[2].replace('"', '').replace(',', '_') + possible_events =3D line[-2].replace('"', '').replace("\\n= ", " ") for event in possible_events.split(): matrix[states_dict[origin_state]][events_dict[event]] = =3D dest_state cursor +=3D 1 diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index b3a49779d4cc5..6ab519b03789c 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -137,7 +137,7 @@ class Dot2c(Automata): line +=3D f"\t\t\t{next_state}" else: line +=3D f"{next_state:>{maxlen}}" - if y !=3D nr_events-1: + if y !=3D nr_events - 1: line +=3D ",\n" if linetoolong else ", " else: line +=3D ",\n\t\t}," if linetoolong else " }," diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index c70a9812abbf6..4bf0db52e6264 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -111,8 +111,8 @@ class dot2k(Monitor, Dot2c): tp_args =3D tp_args_event if tp_type =3D=3D "event" else tp_args_e= rror if self.monitor_type =3D=3D "per_task": tp_args.insert(0, tp_args_id) - tp_proto_c =3D ", ".join([a+b for a,b in tp_args]) - tp_args_c =3D ", ".join([b for a,b in tp_args]) + tp_proto_c =3D ", ".join([a + b for a, b in tp_args]) + tp_args_c =3D ", ".join([b for a, b in tp_args]) buff.append(f" TP_PROTO({tp_proto_c}),") buff.append(f" TP_ARGS({tp_args_c})") return '\n'.join(buff) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index a3fbb1ac74916..31c454329e8e1 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -228,7 +228,7 @@ obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors/{name}/{na= me}.o =20 =20 class Monitor(RVGenerator): - monitor_types =3D { "global" : 1, "per_cpu" : 2, "per_task" : 3 } + monitor_types =3D {"global": 1, "per_cpu": 2, "per_task": 3} =20 def __init__(self, extra_params=3D{}): super().__init__(extra_params) --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EC0E427F749 for ; Wed, 4 Feb 2026 14:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216772; cv=none; b=YmqZ6LJ6NOqHctztDBzsM9R27/aWnTz6hh+OrIIMUQd+dgPN3pjGZfYuuXftpEKjRFT4KspFTWn7qDRu2Z9hbQrcWiItRPG1Xr+iL9hF3X/0GesaEzVc1riuYdma1gwKmBbYIUOek3ueTfdMwtrFetYRzg25aTZlmaFxyvMRrIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216772; c=relaxed/simple; bh=RzD5D5fXRBq5Dbj8AC1pdHSI8YInCViioqXr/ESnnCs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hVhplb3DSAvtFHN777dJ4v0cNniQuyOWq6tiSafuUvpkr+bqt23UT5w5P7I0+cYHxemEdsnX2jX7/tGC85eTLNTXvWeM994FIGOKDdT1yxX0EwqPfSdZ91X6rpTqizKfJQT4zSFDdc7VnJaMWUhnz2L3j3Lh5+n8sXJTwOuM75M= 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=Zi3/XXaI; arc=none smtp.client-ip=170.10.129.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="Zi3/XXaI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xXfGMOmVzPizwSIz/3wbC9ez+h/caatHyVW51rPHiK4=; b=Zi3/XXaIuECFP1NrcwNU1/QparaX99GIC5oR8SzkoOa6SsBvqSxCs8P5XEvxVqTNLtCVTz qFEqSusbCQwcd6ZEfc+bCZBcXjw1HO04pjseu3GprnMqV0Aou1zXOI9vxgom6NPVQHu6RJ tbRWi40+8sf2D0jVv3uOuDM9lJ2XPFA= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-1jQGqCavO2-etlYfztdLiA-1; Wed, 04 Feb 2026 09:52:50 -0500 X-MC-Unique: 1jQGqCavO2-etlYfztdLiA-1 X-Mimecast-MFC-AGG-ID: 1jQGqCavO2-etlYfztdLiA_1770216769 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F14F3180047F; Wed, 4 Feb 2026 14:52:48 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 79CD330001A5; Wed, 4 Feb 2026 14:52:46 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 09/20] rv/rvgen: fix DOT file validation logic error Date: Wed, 4 Feb 2026 11:42:35 -0300 Message-ID: <20260204144914.104028-10-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix incorrect boolean logic in automata DOT file format validation that allowed malformed files to pass undetected. The previous implementation used a logical AND operator where OR was required, causing the validation to only reject files when both the first token was not "digraph" AND the second token was not "state_automaton". This meant a file starting with "digraph" but having an incorrect second token would incorrectly pass validation. The corrected logic properly rejects DOT files where either the first token is not "digraph" or the second token is not "state_automaton", ensuring that only properly formatted automaton definition files are accepted for processing. Without this fix, invalid DOT files could cause downstream parsing failures or generate incorrect C code for runtime verification monitors. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index deb1f09556c3c..38035d59cdd51 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -59,7 +59,7 @@ class Automata: # checking the first line: line =3D dot_lines[cursor].split() =20 - if (line[0] !=3D "digraph") and (line[1] !=3D "state_automaton"): + if (line[0] !=3D "digraph") or (line[1] !=3D "state_automaton"): raise AutomataError(f"Not a valid .dot format: {self.__dot_pat= h}") else: cursor +=3D 1 --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 420BE3D413D for ; Wed, 4 Feb 2026 14:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216799; cv=none; b=SfM/C8XAA2ETYXgdpUDyMxV4Uo3Mt+w2Ul0c87CHSNQUQN5LPigbXGQUkJ0VtRe2lRXqwKfxJ0/2QQMJKqFFB/yXZFaYxrTlZfYzrnk274PcKfDZeAm6D1X2naHf8GJyjC1fxWWxn/XKdurXenPvNBjSkVvytWhDyxwZKsktvwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216799; c=relaxed/simple; bh=zkKfAYsjci/mlp9ECo2S4q4Ily6MLqxWuVPZNo/DVOQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rBxJEbZfkwmT+pXyZIvKwnb9MsewQ7DYNGcbq1Xw/X/QWGiZwIcyIAjgSsdj83n1zHpSEDKO+JaHVsWLJi/FfnWTtSuxOTg8Re/yq/N1n4UbarjE8HLyj+ncYTv+QeJnSKsr8Q66kSqtV0w16rHdi49I8z5n8P68t4bbkCUEC5k= 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=X5+wp9A+; arc=none smtp.client-ip=170.10.129.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="X5+wp9A+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O5AkGAtQbdmjDKuC0+IkHG8P8bWUzPyG8UBDaopQLy0=; b=X5+wp9A+uCjLslJbFLoYQXOJoKZrHjCP3IviuNYPYKSGYz50dTy2Pk2JCRbFRhp3JuR6if hJtKfJ3Q3oYiTT7syrsoAXFUFWPuwA2OLQWkBsCZwzTzVPl/nd8L9gub4YfEBqUj28wOz3 j7J1aeTTA1pzYOUtOIto41d100kLrG0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-22MzpEPaN5-TCngGQ9Y8-g-1; Wed, 04 Feb 2026 09:53:11 -0500 X-MC-Unique: 22MzpEPaN5-TCngGQ9Y8-g-1 X-Mimecast-MFC-AGG-ID: 22MzpEPaN5-TCngGQ9Y8-g_1770216789 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B09AF1955F3D; Wed, 4 Feb 2026 14:53:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 336C43000221; Wed, 4 Feb 2026 14:53:06 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 10/20] rv/rvgen: use class constant for init marker Date: Wed, 4 Feb 2026 11:42:36 -0300 Message-ID: <20260204144914.104028-11-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Replace hardcoded string literal and magic number with a class constant for the initial state marker in DOT file parsing. The previous implementation used the magic string "__init_" directly in the code along with a hardcoded length of 7 for substring extraction, which made the code less maintainable and harder to understand. This change introduces a class constant init_marker to serve as a single source of truth for the initial state prefix. The code now uses startswith() for clearer intent and calculates the substring position dynamically using len(), eliminating the magic number. If the marker value needs to change in the future, only the constant definition requires updating rather than multiple locations in the code. The refactoring improves code readability and maintainability while preserving the exact same runtime behavior. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 38035d59cdd51..035d0e8c12c9a 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -25,6 +25,7 @@ class Automata: """ =20 invalid_state_str =3D "INVALID_STATE" + init_marker =3D "__init_" =20 def __init__(self, file_path, model_name=3DNone): self.__dot_path =3D file_path @@ -96,8 +97,8 @@ class Automata: =20 # "enabled_fired"}; -> enabled_fired state =3D raw_state.replace('"', '').replace('};', '').replace= (',', '_') - if state[0:7] =3D=3D "__init_": - initial_state =3D state[7:] + if state.startswith(self.init_marker): + initial_state =3D state[len(self.init_marker):] else: states.append(state) if "doublecircle" in self.__dot_lines[cursor]: --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 F020C3D413D for ; Wed, 4 Feb 2026 14:53:35 +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=1770216816; cv=none; b=bsouGHldON3PbIwv9UfDNW9UJ8QpXLaQU1J/R4FkznCu68ixE0H1MCoRaqw3z7l+i0YtzZ3p8XUBJkh2YEf5jYt4pG0mLbvYk71gpF/bv9K+22KD9iq1/xetCUQhOlJak/mJhw2EPG1uszPaqou/M6NgmE5ACUy2xPl0M5MI0bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216816; c=relaxed/simple; bh=oB+teQBhycXTJdlwcukDDx7RdUGC0hM3BCcbfyYIcwg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P/gmwX8pLGrHDItk0aRPbOxJQy+EfJ3cCbTruXfkWTP21tbbW5KuV7C/Y5MsCTwxlHJ42WzAsyuyR6A4QOpuIkNI5dAHmBVilSh4L29P9Qk+sieHPG2uJLZV+tEYwZNIDVkn/j56h1yXMQ5lRtJwHgw5LkAruTniKwMwiq3uUws= 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=gG6eY/Xj; 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="gG6eY/Xj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rlrrS/RcZ539pQ1nZ2tB/JpUo/QTXY6OW554Mgs3//I=; b=gG6eY/XjQyQ6s7q/8WYfnNu9CipViN5vzn/OINhFytjGk6IaRNXp2smNesJTAXFWGGxoed PSLj+m/bfI/cgP7SYTgESdTPpZEGMjEgZGAxN1NNwcA1ALQs5ohumnRe1ir9dOgF98a//5 GnKnTe961nolag6sGWjjGibOL9wWfK0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-08YEnzvBMhWUuKv7uCXM_w-1; Wed, 04 Feb 2026 09:53:31 -0500 X-MC-Unique: 08YEnzvBMhWUuKv7uCXM_w-1 X-Mimecast-MFC-AGG-ID: 08YEnzvBMhWUuKv7uCXM_w_1770216810 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E6F9195609F; Wed, 4 Feb 2026 14:53:30 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E32CB30001A5; Wed, 4 Feb 2026 14:53:27 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 11/20] rv/rvgen: refactor automata.py to use iterator-based parsing Date: Wed, 4 Feb 2026 11:42:37 -0300 Message-ID: <20260204144914.104028-12-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Refactor the DOT file parsing logic in automata.py to use Python's iterator-based patterns instead of manual cursor indexing. The previous implementation relied on while loops with explicit cursor management, which made the code prone to off-by-one errors and would crash on malformed input files containing empty lines. The new implementation uses enumerate and itertools.islice to iterate over lines, eliminating manual cursor tracking. Functions that search for specific markers now use for loops with early returns and explicit AutomataError exceptions for missing markers, rather than assuming the markers exist. Additional bounds checking ensures that split line arrays have sufficient elements before accessing specific indices, preventing IndexError exceptions on malformed DOT files. The matrix creation and event variable extraction methods now use functional patterns with map combined with itertools.islice, making the intent clearer while maintaining the same behavior. Minor improvements include using extend instead of append in a loop, adding empty file validation, and replacing enumerate with range where the enumerated value was unused. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 109 +++++++++++++-------- 1 file changed, 67 insertions(+), 42 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 035d0e8c12c9a..17b012b868531 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -9,6 +9,7 @@ # Documentation/trace/rv/deterministic_automata.rst =20 import ntpath +from itertools import islice =20 class AutomataError(Exception): """Exception raised for errors in automata parsing and validation. @@ -49,37 +50,54 @@ class Automata: return model_name =20 def __open_dot(self) -> list[str]: - cursor =3D 0 dot_lines =3D [] try: with open(self.__dot_path) as dot_file: - dot_lines =3D dot_file.read().splitlines() + dot_lines =3D dot_file.readlines() except OSError as exc: raise AutomataError(f"Cannot open the file: {self.__dot_path}"= ) from exc =20 + if not dot_lines: + raise AutomataError(f"{self.__dot_path} is empty") + # checking the first line: - line =3D dot_lines[cursor].split() + line =3D dot_lines[0].split() =20 - if (line[0] !=3D "digraph") or (line[1] !=3D "state_automaton"): + if len(line) < 2 or line[0] !=3D "digraph" or line[1] !=3D "state_= automaton": raise AutomataError(f"Not a valid .dot format: {self.__dot_pat= h}") - else: - cursor +=3D 1 + return dot_lines =20 def __get_cursor_begin_states(self) -> int: - cursor =3D 0 - while self.__dot_lines[cursor].split()[0] !=3D "{node": - cursor +=3D 1 - return cursor + for cursor, line in enumerate(self.__dot_lines): + split_line =3D line.split() + + if len(split_line) and split_line[0] =3D=3D "{node": + return cursor + + raise AutomataError("Could not find a beginning state") =20 def __get_cursor_begin_events(self) -> int: - cursor =3D 0 - while self.__dot_lines[cursor].split()[0] !=3D "{node": - cursor +=3D 1 - while self.__dot_lines[cursor].split()[0] =3D=3D "{node": - cursor +=3D 1 - # skip initial state transition - cursor +=3D 1 + state =3D 0 + cursor =3D 0 # make pyright happy + + for cursor, line in enumerate(self.__dot_lines): + line =3D line.split() + if not line: + continue + + if state =3D=3D 0: + if line[0] =3D=3D "{node": + state =3D 1 + elif line[0] !=3D "{node": + break + else: + raise AutomataError("Could not find beginning event") + + cursor +=3D 1 # skip initial state transition + if cursor =3D=3D len(self.__dot_lines): + raise AutomataError("Dot file ended after event beginning") + return cursor =20 def __get_state_variables(self) -> tuple[list[str], str, list[str]]: @@ -91,9 +109,12 @@ class Automata: cursor =3D self.__get_cursor_begin_states() =20 # process nodes - while self.__dot_lines[cursor].split()[0] =3D=3D "{node": - line =3D self.__dot_lines[cursor].split() - raw_state =3D line[-1] + for line in islice(self.__dot_lines, cursor, None): + split_line =3D line.split() + if not split_line or split_line[0] !=3D "{node": + break + + raw_state =3D split_line[-1] =20 # "enabled_fired"}; -> enabled_fired state =3D raw_state.replace('"', '').replace('};', '').replace= (',', '_') @@ -101,16 +122,14 @@ class Automata: initial_state =3D state[len(self.init_marker):] else: states.append(state) - if "doublecircle" in self.__dot_lines[cursor]: + if "doublecircle" in line: final_states.append(state) has_final_states =3D True =20 - if "ellipse" in self.__dot_lines[cursor]: + if "ellipse" in line: final_states.append(state) has_final_states =3D True =20 - cursor +=3D 1 - states =3D sorted(set(states)) states.remove(initial_state) =20 @@ -123,26 +142,27 @@ class Automata: return states, initial_state, final_states =20 def __get_event_variables(self) -> list[str]: + events: list[str] =3D [] # here we are at the begin of transitions, take a note, we will re= turn later. cursor =3D self.__get_cursor_begin_events() =20 - events =3D [] - while self.__dot_lines[cursor].lstrip()[0] =3D=3D '"': + for line in map(str.lstrip, islice(self.__dot_lines, cursor, None)= ): + if not line.startswith('"'): + break + # transitions have the format: # "all_fired" -> "both_fired" [ label =3D "disable_irq" ]; # ------------ event is here ------------^^^^^ - if self.__dot_lines[cursor].split()[1] =3D=3D "->": - line =3D self.__dot_lines[cursor].split() - event =3D line[-2].replace('"', '') + split_line =3D line.split() + if len(split_line) > 1 and split_line[1] =3D=3D "->": + event =3D split_line[-2].replace('"', '') =20 # when a transition has more than one labels, they are lik= e this # "local_irq_enable\nhw_local_irq_enable_n" # so split them. =20 event =3D event.replace("\\n", " ") - for i in event.split(): - events.append(i) - cursor +=3D 1 + events.extend(event.split()) =20 return sorted(set(events)) =20 @@ -163,31 +183,36 @@ class Automata: nr_state +=3D 1 =20 # declare the matrix.... - matrix =3D [[self.invalid_state_str for x in range(nr_event)] for = y in range(nr_state)] + matrix =3D [[self.invalid_state_str for _ in range(nr_event)] for = _ in range(nr_state)] =20 # and we are back! Let's fill the matrix cursor =3D self.__get_cursor_begin_events() =20 - while self.__dot_lines[cursor].lstrip()[0] =3D=3D '"': - if self.__dot_lines[cursor].split()[1] =3D=3D "->": - line =3D self.__dot_lines[cursor].split() - origin_state =3D line[0].replace('"', '').replace(',', '_') - dest_state =3D line[2].replace('"', '').replace(',', '_') - possible_events =3D line[-2].replace('"', '').replace("\\n= ", " ") + for line in map(str.lstrip, + islice(self.__dot_lines, cursor, None)): + + if not line or line[0] !=3D '"': + break + + split_line =3D line.split() + + if len(split_line) > 2 and split_line[1] =3D=3D "->": + origin_state =3D split_line[0].replace('"', '').replace(',= ', '_') + dest_state =3D split_line[2].replace('"', '').replace(',',= '_') + possible_events =3D split_line[-2].replace('"', '').replac= e("\\n", " ") for event in possible_events.split(): matrix[states_dict[origin_state]][events_dict[event]] = =3D dest_state - cursor +=3D 1 =20 return matrix =20 def __store_init_events(self) -> tuple[list[bool], list[bool]]: events_start =3D [False] * len(self.events) events_start_run =3D [False] * len(self.events) - for i, _ in enumerate(self.events): + for i in range(len(self.events)): curr_event_will_init =3D 0 curr_event_from_init =3D False curr_event_used =3D 0 - for j, _ in enumerate(self.states): + for j in range(len(self.states)): if self.function[j][i] !=3D self.invalid_state_str: curr_event_used +=3D 1 if self.function[j][i] =3D=3D self.initial_state: --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1EC0A41B367 for ; Wed, 4 Feb 2026 14:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216837; cv=none; b=uaBtPqGlcZBIS4xefp1alALt+DheDjejbtBNGwsFS40FLyTspLH9LhdEwfrPB2pqtXkkupN8gop8FLG+yCR0co+FDdE3H5tXB1nq85b5CEJ4iOK5Vfp8y7a4kNoP0lTRo1mgx3GQv9n1vhxZmY6IXa0jUuuF5kH/5sbT9oOjJGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216837; c=relaxed/simple; bh=EysKJO4+ELV1hMapeX9UIZZoaG0H7kYvuW0kN70JqXs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RRLotuhiJKQzzRTOmVxcroas80hskBAa1shQn+oG44XhWGLGWgI0SRS5vtaIZmcMDCvMt4nByGs2b0Jdyo0huv2c11MIkbQSfVbJZx4dV3zPxnngP3H+LwCM+zLXW6tVDnRQ4+Rxomxif6nFu+4aC/uIlPzHBJZBuBUTcHI5Yx4= 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=Mz8JyUEe; arc=none smtp.client-ip=170.10.129.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="Mz8JyUEe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A2SDTlZuasG2/vXuJ8H6Rgrikxs2PCC3Qj6tExL/nIo=; b=Mz8JyUEeKbJx9mTPTsP1tKgWLXHerRVe+1OA7qz7e6eWiAX60mFgzeB/Hwuw87btZnN3mk xbc6PKVF4P0cucDUiHCkqrq0OXdnoHWRM7RtiXzOo5QsUoKd+kzhAxL/PUVf8MRfNIO9Qi 6mm3XPq6GQnXSVll4KO7y1LVmkY/RWk= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-Y_-aiDdpPgWWlIH4tc230w-1; Wed, 04 Feb 2026 09:53:51 -0500 X-MC-Unique: Y_-aiDdpPgWWlIH4tc230w-1 X-Mimecast-MFC-AGG-ID: Y_-aiDdpPgWWlIH4tc230w_1770216830 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A600B18001D1; Wed, 4 Feb 2026 14:53:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 26CD130001A5; Wed, 4 Feb 2026 14:53:47 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 12/20] rv/rvgen: remove unused sys import from dot2c Date: Wed, 4 Feb 2026 11:42:38 -0300 Message-ID: <20260204144914.104028-13-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The sys module was imported in the dot2c frontend script but never used. This import was likely left over from earlier development or copied from a template that required sys for exit handling. Remove the unused import to clean up the code and satisfy linters that flag unused imports as errors. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/dot2c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/verification/rvgen/dot2c b/tools/verification/rvgen/dot2c index bf0c67c5b66c8..1012becc7fab6 100644 --- a/tools/verification/rvgen/dot2c +++ b/tools/verification/rvgen/dot2c @@ -16,7 +16,6 @@ if __name__ =3D=3D '__main__': from rvgen import dot2c import argparse - import sys =20 parser =3D argparse.ArgumentParser(description=3D'dot2c: converts a .d= ot file into a C structure') parser.add_argument('dot_file', help=3D'The dot file to be converted') --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 3018F27F749 for ; Wed, 4 Feb 2026 14:54:16 +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=1770216856; cv=none; b=lGhsfrrLS4yWnJ7yG8R8Fo/VL38B+5Wky7kQUeTNFma9bkP6pxyAxo+CiCMBSl3mK+cL+Pj/NH4uC7dY6k7tEAsQn0jbr+AhYK/8gSstP7M2ixF76ExQ/McmEOEFO7GSK8UGg/zosA/sit6tSCP9Zmr/PGdm6KoCCpODu7e/a90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216856; c=relaxed/simple; bh=/Gpqv79U2S00zo9a7zY7AaE+cnW02/ouX1T7f4+Ng34=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nMmm1KjpMuqMKT5xMKF2yi7ZYgzuz41W4dFMAaSSDiXv1supOJwoTuzhMVIqOLFtb+Bq+CrySPxA/DWZdgJ/6dBOKUlrzP8u8N5u7fm+BB53ooYaobhCGsuCe1ffPfjG1hGKBT0F9UAhaZcfjVmb82VplRANHykbwVgfuHvFdF4= 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=IKJsYDz6; 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="IKJsYDz6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4sKMhVxePK4zfkjpLf50eQqIDuXbhhCmqVw0kSawiaE=; b=IKJsYDz6SyL7vn6PjAYUCYBjr6y/YnDqOUoB7WsD2fdo7ERPokloHcthhWEL5YL5uTrpmn 98mjQaLJGAzX4Ctk3pdRd10GCiZ7IayZDCyoofSDlKW13pEnFdVRXDodWGajojCnm+MdsE J1ZmSqyCCjPEpJBwrWr++2uHZZzf/P8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-ItxIA8W1OjaJs37lndZHLQ-1; Wed, 04 Feb 2026 09:54:12 -0500 X-MC-Unique: ItxIA8W1OjaJs37lndZHLQ-1 X-Mimecast-MFC-AGG-ID: ItxIA8W1OjaJs37lndZHLQ_1770216851 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D1B21956052; Wed, 4 Feb 2026 14:54:11 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7CD3730001BC; Wed, 4 Feb 2026 14:54:08 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 13/20] rv/rvgen: remove unused __get_main_name method Date: Wed, 4 Feb 2026 11:42:39 -0300 Message-ID: <20260204144914.104028-14-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The __get_main_name() method in the generator module is never called from anywhere in the codebase. Remove this dead code to improve maintainability. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/generator.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index 31c454329e8e1..ef6c9150f50c6 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -205,12 +205,6 @@ obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors/{name}/{n= ame}.o path =3D os.path.join(self.rv_dir, "monitors", path) self.__write_file(path, content) =20 - def __get_main_name(self): - path =3D f"{self.name}/main.c" - if not os.path.exists(path): - return "main.c" - return "__main.c" - def print_files(self): main_c =3D self.fill_main_c() =20 --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 8B12E41B352 for ; Wed, 4 Feb 2026 14:54:35 +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=1770216875; cv=none; b=uNmh8deocI0P+6D9KM0BIbIU3jCQxj0ulWBxvHwJuWWAIHfaqdBo3shBFTi/dUZaEhj7Ulb/DBsc50erjVMvx1x2nKliEckGPKUIM47S4RNi4nPCUAGm9kiSeTm4rntu4Lh90rAnYp1ALnFHFPONns18fxmZRebkxNA6akHQMoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216875; c=relaxed/simple; bh=+ffhunU6OovmpNadMKHHv6k31yBcnO46ZwFSJGigcH8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pkJFA2P6EDneduKtRAR6ZU42uYmVLQa/ij3U63TuSCp0yu8eGKBKfFslAsWr4hyheO/OwQ99/LyAGuvm5FobrIShAFAA7wnTz0AQEFfvr8vjpenoqIO5IvTgKStNyjIfgwk1oJDEXAnn+viAkEWSCRXwdbqk8+jJSOhVXuuxzF0= 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=ADpGZaS/; 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="ADpGZaS/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=23hZsiknSb9Xi6KPa+kRsw/9VzcEStpN4mBV0Kd68lM=; b=ADpGZaS/imrmX0BS4EFyZekN+0zstD1wIN7rghksIvcREv030bPP5uct8sabv0tQpYOwDs Gt8MeknpwNQZ/zSny7oUTPbyPX5ZPBpUw9vLVJEQgYklOaYC7yG3qhJ9ITqkmhK3nAsvKB 5C80CiQ8Xaag9bL7wUxC+3LHFKMmHtE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-IheHmhcTONmdqyUNaipxfg-1; Wed, 04 Feb 2026 09:54:32 -0500 X-MC-Unique: IheHmhcTONmdqyUNaipxfg-1 X-Mimecast-MFC-AGG-ID: IheHmhcTONmdqyUNaipxfg_1770216871 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1A15319560A5; Wed, 4 Feb 2026 14:54:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97FE130001A5; Wed, 4 Feb 2026 14:54:28 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 14/20] rv/rvgen: make monitor arguments required in rvgen Date: Wed, 4 Feb 2026 11:42:40 -0300 Message-ID: <20260204144914.104028-15-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Add required=3DTrue to the monitor subcommand arguments for class, spec, and monitor_type in rvgen. These arguments are essential for monitor generation and attempting to run without them would cause AttributeError exceptions later in the code when the script tries to access them. Making these arguments explicitly required provides clearer error messages to users at parse time rather than cryptic exceptions during execution. This improves the user experience by catching missing arguments early with helpful usage information. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvge= n/__main__.py index 50b7d4227fb16..c4c795c15e853 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -32,10 +32,11 @@ if __name__ =3D=3D '__main__': monitor_parser.add_argument('-n', "--model_name", dest=3D"model_name") monitor_parser.add_argument("-p", "--parent", dest=3D"parent", required=3DFalse, help=3D"Create a monitor= nested to parent") - monitor_parser.add_argument('-c', "--class", dest=3D"monitor_class", + monitor_parser.add_argument('-c', "--class", dest=3D"monitor_class", r= equired=3DTrue, help=3D"Monitor class, either \"da\" or \"= ltl\"") - monitor_parser.add_argument('-s', "--spec", dest=3D"spec", help=3D"Mon= itor specification file") - monitor_parser.add_argument('-t', "--monitor_type", dest=3D"monitor_ty= pe", + monitor_parser.add_argument('-s', "--spec", dest=3D"spec", required=3D= True, + help=3D"Monitor specification file") + monitor_parser.add_argument('-t', "--monitor_type", dest=3D"monitor_ty= pe", required=3DTrue, help=3Df"Available options: {', '.join(Mon= itor.monitor_types.keys())}") =20 container_parser =3D subparsers.add_parser("container") --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 DAAB34219FA for ; Wed, 4 Feb 2026 14:54:55 +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=1770216896; cv=none; b=UtpcnBA0TuJ7SoCCwdlE3SY99SI4ZIWDVqdUnpAB7bLLCQuE0jZ6W8MyT5la3nfWSTq/9EXogAOWWP15Qn0lfig9dEhSNid4WOJuJ9FU5GVRRnrSAOuPrLGqrBH2UZ85YZ2zsQS77Q/QbxMXJrariAUlSHCKQM9Qvxrm4AXLgRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216896; c=relaxed/simple; bh=7VkHUZ85BsRXWcQ1fJVsqBu4kJDs32MwdEPil2AgmiY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oM/QegIC/8CfsY+W0cMmEKNFfKaXeEO5NLlPDkue0XpUg4b1i0ghComR3yhYNXEXsTyZDoVbTw+hTaB8KxYzpYwWXw5HDn51KqyHmqNTHafARu4zGITnI3qZzR/ctMJi8gBbf5f1WvCU006dTMXeQgAThV0+9vXj2E85m2IYe18= 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=bgtmMy7n; 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="bgtmMy7n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K5nDGm8I1q8jSi+6bxCtbd9yEAB2mdaSd/Cp83kNOj4=; b=bgtmMy7nv6kL0qv8XphBf3EUZxYkyq8qWD9Od7F4IF3kZCbuKs4Z8xFl9o8/uTLZ+dmSWH pFROgsnW+m9i0IN6/r79FKUM8NYRDQ+UHEWRA25rkWTVWZL9hRnmttFLL0pMQB4DxigFLy ByXLcgRp7BJw0VpZKhMzRXcOOjSUfC8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-U8IYSYn7NVy6juP88Be2bQ-1; Wed, 04 Feb 2026 09:54:53 -0500 X-MC-Unique: U8IYSYn7NVy6juP88Be2bQ-1 X-Mimecast-MFC-AGG-ID: U8IYSYn7NVy6juP88Be2bQ_1770216892 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 70A45180025F; Wed, 4 Feb 2026 14:54:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 26F7A30001B9; Wed, 4 Feb 2026 14:54:48 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 15/20] rv/rvgen: fix isinstance check in Variable.expand() Date: Wed, 4 Feb 2026 11:42:41 -0300 Message-ID: <20260204144914.104028-16-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The Variable.expand() method in ltl2ba.py performs contradiction detection by checking if a negated variable already exists in the graph node's old set. However, the isinstance check was incorrectly testing the ASTNode wrapper instead of the wrapped operator, causing the check to always return False. The old set contains ASTNode instances which wrap LTL operators via their .op attribute. The fix changes isinstance(f, NotOp) to isinstance(f.op, NotOp) to correctly examine the wrapped operator type. This follows the established pattern used elsewhere in the file, such as the iteration at lines 572-574 which accesses o.op.is_temporal() on items from node.old. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/ltl2ba.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/ltl2ba.py b/tools/verification/= rvgen/rvgen/ltl2ba.py index f14e6760ac3db..28f9a5682c830 100644 --- a/tools/verification/rvgen/rvgen/ltl2ba.py +++ b/tools/verification/rvgen/rvgen/ltl2ba.py @@ -394,7 +394,7 @@ class Variable: @staticmethod def expand(n: ASTNode, node: GraphNode, node_set) -> set[GraphNode]: for f in node.old: - if isinstance(f, NotOp) and f.op.child is n: + if isinstance(f.op, NotOp) and f.op.child is n: return node_set node.old |=3D {n} return node.expand(node_set) --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 503A941C2E4 for ; Wed, 4 Feb 2026 14:55: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=1770216917; cv=none; b=CrYkN/YMSoRZ6REFGqBa9cG0WtBYFLFXktaiTZ/338kPUXlozk106xPDI/TQEgVeBvDho5tw9Kn/70SCmnFSX52Z4QOUfb13IYWiQJPurBMbMP+nipgQcINSYVj4r/7M1MNhLdHKTKmyKkVessCcHjJjqNIoJqywWsPOA1Gk2P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216917; c=relaxed/simple; bh=iEhhcJ2x8m7qLdgs93Q1jzeQeoShFixGz5NGOxbtWK8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwQaw94Fl468+dFXFb31v8TbN7zT6ufGukadBdJ/Qz5gkJhGyMo0czmjFFR+OKGYlyV5Kk9ObhBFmeav99uvj6Zs5aOnbKbSI1S+1sHlpkmIAs+TcHPA9YUZ3PnKtAKWKRN0AViuxcJCsFAD+kVk13r/uUfSC/ApUdECgC1hLEs= 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=JjlOxFtJ; 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="JjlOxFtJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y0JzYhi+/A6H34SSd4lFWPfJJhN4jIR9kEhWAeuzvLE=; b=JjlOxFtJEPp9YuHCiRixpPapAKDMlinkN1w7/TLXNHaEa2luUs9EkuywIC98pJweZ/Kfv8 /VlBhrJKCctabgnWr0EyTP/9pZoJFzljd1D2NgWKqmgI6BHt/8zZWlIBgepUp1B4LkT9UR me2V/sArsE93mkvy/rd378Aoou5sHJY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-sCtI_f4lOR-AKj6iCwzPjA-1; Wed, 04 Feb 2026 09:55:14 -0500 X-MC-Unique: sCtI_f4lOR-AKj6iCwzPjA-1 X-Mimecast-MFC-AGG-ID: sCtI_f4lOR-AKj6iCwzPjA_1770216913 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E53A81955F3B; Wed, 4 Feb 2026 14:55:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C78130001A5; Wed, 4 Feb 2026 14:55:10 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 16/20] rv/rvgen: extract node marker string to class constant Date: Wed, 4 Feb 2026 11:42:42 -0300 Message-ID: <20260204144914.104028-17-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Add a node_marker class constant to the Automata class to replace the hardcoded "{node" string literal used throughout the DOT file parsing logic. This follows the existing pattern established by the init_marker and invalid_state_str class constants in the same class. The "{node" string is used as a marker to identify node declaration lines in DOT files during state variable extraction and cursor positioning. Extracting it to a named constant improves code maintainability and makes the marker's purpose explicit. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 17b012b868531..270a3d0bf4ce7 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -27,6 +27,7 @@ class Automata: =20 invalid_state_str =3D "INVALID_STATE" init_marker =3D "__init_" + node_marker =3D "{node" =20 def __init__(self, file_path, model_name=3DNone): self.__dot_path =3D file_path @@ -72,7 +73,7 @@ class Automata: for cursor, line in enumerate(self.__dot_lines): split_line =3D line.split() =20 - if len(split_line) and split_line[0] =3D=3D "{node": + if len(split_line) and split_line[0] =3D=3D self.node_marker: return cursor =20 raise AutomataError("Could not find a beginning state") @@ -87,9 +88,9 @@ class Automata: continue =20 if state =3D=3D 0: - if line[0] =3D=3D "{node": + if line[0] =3D=3D self.node_marker: state =3D 1 - elif line[0] !=3D "{node": + elif line[0] !=3D self.node_marker: break else: raise AutomataError("Could not find beginning event") @@ -111,7 +112,7 @@ class Automata: # process nodes for line in islice(self.__dot_lines, cursor, None): split_line =3D line.split() - if not split_line or split_line[0] !=3D "{node": + if not split_line or split_line[0] !=3D self.node_marker: break =20 raw_state =3D split_line[-1] --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 E5F5042188A for ; Wed, 4 Feb 2026 14:55:38 +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=1770216939; cv=none; b=CZzAk0V0HoJx1cGmZWgbY5h7zgM4aILNWtbWntSrlxYHj1Q1CS+q8PM6wzydOG+7XTzuflYDgW6y6K/wVGwVPeRZVtmmN9D0nYdpW/1/DoBIIGAPDgghgPUhDeff9cdeVu//mB2wQbtPwLmEklt5x/JZCZ/BT2N6+TPbJJa16P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216939; c=relaxed/simple; bh=KVa8VWvbhQKvIriopPHHlNR0vTBDZhyOsZUnhGC72wA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ooCbagLYC4g0OEhYG/bx+91PbjDxaQ1yCHyE1ZtNys7x6GG2DdmF5rxASbSVqZWqEPUmB33mLrkfxzUaQwU2ytJMTE6SNSyAFy1kkFeSGoxqxkyYtHF3XR9zCjc4rIXRnMJVYv0W0IMs1AUJbablstaNwrgPoIf/299suN3g7QI= 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=KbmsDtrR; 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="KbmsDtrR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8oc96eGDWBd34YoQhzQwIqlhjlF2jy/e1m69Oi5R+l4=; b=KbmsDtrRsUEsKFzFpXvlbvV41550ug6Tt7p0WqhzMAUamQOxyy+tz9l0tnHBZXz7WoJGa6 BJAwwAnJnYcuZKVFGhkSltTGTSIAyYOp53Ib+HujprONib0VNyxwjYN51bwyN8GmUyMY29 Qd6Zt4SZgok86gHxTrk33qglOQ0trYQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-SYGxsOCAPFyTZOxB7DJZXQ-1; Wed, 04 Feb 2026 09:55:34 -0500 X-MC-Unique: SYGxsOCAPFyTZOxB7DJZXQ-1 X-Mimecast-MFC-AGG-ID: SYGxsOCAPFyTZOxB7DJZXQ_1770216933 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 675511956070; Wed, 4 Feb 2026 14:55:33 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E425130001A5; Wed, 4 Feb 2026 14:55:30 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 17/20] rv/rvgen: enforce presence of initial state Date: Wed, 4 Feb 2026 11:42:43 -0300 Message-ID: <20260204144914.104028-18-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The __get_state_variables() method parses DOT files to identify the automaton's initial state. If the input file lacks a node with the required initialization prefix, the initial_state variable is referenced before assignment, causing an UnboundLocalError or a generic error during the state removal step. Initialize the variable explicitly and validate that a start node was found after parsing. Raise a descriptive AutomataError if the definition is missing to improve debugging and ensure the automaton is valid. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 270a3d0bf4ce7..cf82f04dbc661 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -105,6 +105,7 @@ class Automata: # wait for node declaration states =3D [] final_states =3D [] + initial_state =3D "" =20 has_final_states =3D False cursor =3D self.__get_cursor_begin_states() @@ -131,6 +132,9 @@ class Automata: final_states.append(state) has_final_states =3D True =20 + if not initial_state: + raise AutomataError("The automaton doesn't have an initial sta= te") + states =3D sorted(set(states)) states.remove(initial_state) =20 --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 2CDEE41B37B for ; Wed, 4 Feb 2026 14:55:56 +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=1770216957; cv=none; b=LkAfYiWkbJS6zIAm9FgL0F+jeGsJSbMLpWHoDYlQuSLfvGdY/p8Hm9vMrA2yI5Ng/NvsD18c0y1tHWYT6TECqHIWSwisZkqOKXE8+38rurdmXUO48Nrjzvny7h813cQoZ39qRgCjZchJ8lJ6OEXm//vXn5yzQvuEiS71CDShw44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216957; c=relaxed/simple; bh=aqVw+KwudE2PMyQ5c7D0mNKToCJ+MFm+4+/iUzlVPSg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eCTIVrbHW7/RqWCpO4knRzn3K9d/dYxt9mvHvmB2xcBQFQKJo3Z6rrEHSb0oDEVYxTwDIEgzRgqDm2+otNsqV1jcJRFGZV4kONTe6xsLNW0GBwQQX0M8i7GLOvQqmsUzApiYyn48F9tJp3Z203ZRoNZy5qsBTr0IdPc7ZvPIsSY= 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=HtRwoQ77; 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="HtRwoQ77" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i4PzDDOnMDtmDhq8eE10nYEtt4SKmr4xmRLUOnegfHQ=; b=HtRwoQ77WcQg+rl/1zgXd94ZNETwnoYwqYwS3puMfF5GekJGJ/NsxYUP9mjLwWdGQ9dLjb 5Od/2V0zvkE+HLoeDuGP9XQibXynqR/tAsz38QamX3SSn00aLD7fhnvZUSpq5AZHFUSYg4 13hYBKpoG8JjxBPF6+UkvmdIAD7eHKM= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-vyQApY_iPmC5BsT3-3wMQQ-1; Wed, 04 Feb 2026 09:55:55 -0500 X-MC-Unique: vyQApY_iPmC5BsT3-3wMQQ-1 X-Mimecast-MFC-AGG-ID: vyQApY_iPmC5BsT3-3wMQQ_1770216954 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC60E180063A; Wed, 4 Feb 2026 14:55:53 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 746A530001A5; Wed, 4 Feb 2026 14:55:51 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 18/20] rv/rvgen: fix unbound loop variable warning Date: Wed, 4 Feb 2026 11:42:44 -0300 Message-ID: <20260204144914.104028-19-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Pyright static analysis reports a "possibly unbound variable" warning for the loop variable `i` in the `abbreviate_atoms` function. The variable is accessed after the inner loop terminates to slice the atom string. While the loop logic currently ensures execution, the analyzer flags the reliance on the loop variable persisting outside its scope. Refactor the prefix length calculation into a nested `find_share_length` helper function. This encapsulates the search logic and uses explicit return statements, ensuring the length value is strictly defined. This satisfies the type checker and improves code readability without altering the runtime behavior. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/ltl2k.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index fa9ea6d597095..2c564cc937235 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -43,13 +43,17 @@ def abbreviate_atoms(atoms: list[str]) -> list[str]: skip =3D ["is", "by", "or", "and"] return '_'.join([x[:2] for x in s.lower().split('_') if x not in s= kip]) =20 - abbrs =3D [] - for atom in atoms: + def find_share_length(atom: str) -> int: for i in range(len(atom), -1, -1): if sum(a.startswith(atom[:i]) for a in atoms) > 1: - break - share =3D atom[:i] - unique =3D atom[i:] + return i + return 0 + + abbrs =3D [] + for atom in atoms: + share_len =3D find_share_length(atom) + share =3D atom[:share_len] + unique =3D atom[share_len:] abbrs.append((shorten(share) + shorten(unique))) return abbrs =20 --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 BBA714219F8 for ; Wed, 4 Feb 2026 14:56: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=1770216978; cv=none; b=e/F3AbGzrs1FF3+fBb61tv8SupVkLsYBi58az71FLajRIn5K0WjYOSQNhCHJbIPRKb1ataFFkkv99/q6WwO3AKazK0IwO4o6YwO9Pzylfh2OqJxAd2p2SM0xUTrR4bzaBoxUjUdEoeo01dkXYUaqvV/g+n4wmH3XkIV81BeOOgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216978; c=relaxed/simple; bh=kGQgel5Bam0L4+dTUknKjj4VeT7+LhGjT7frHIxd5S8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g61NHQ2T+s9EfMjQKaZvAu9FH/3Xh1ABPInJ0FCKlQHOvX8xnHPGZu4mSL03ACUYXIEdio4rTN3Mynqoe9IqiPyqf6zI9LgJwLQvnDhcJMMli5aCJg9n4JlGwUz6e2rFPPcfGi59XD1yPq+1KMYZlF7PMs/L5b2Qxx8iNJRtKzY= 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=X24L2t0E; 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="X24L2t0E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770216977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OTKjXOGKrqTlHNVdJz+DTqnNe/95MpnGXuAdQBexCfc=; b=X24L2t0EZ9kz2Rb3p+UCgA/QOEvLiyYrh1tUr5z/Q2iqdOIuBvvp2XlV7ohIRz1iaKQVwh kJ/wcNLR/x8Og8RA6C8man+zrjzgbfEUwHZ/Hq2YUQI2llUVrKS8qA69rDIuivve7wzuj2 CCnQJ99Qnaon355WOSXaE4Jz8eUQW8E= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-374-tv4_DWIXMtKJMjCtaKQlbg-1; Wed, 04 Feb 2026 09:56:15 -0500 X-MC-Unique: tv4_DWIXMtKJMjCtaKQlbg-1 X-Mimecast-MFC-AGG-ID: tv4_DWIXMtKJMjCtaKQlbg_1770216974 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 910C018004BB; Wed, 4 Feb 2026 14:56:14 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F4EA30001B9; Wed, 4 Feb 2026 14:56:11 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 19/20] rv/rvgen: fix _fill_states() return type annotation Date: Wed, 4 Feb 2026 11:42:45 -0300 Message-ID: <20260204144914.104028-20-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The _fill_states() method returns a list of strings, but the type annotation incorrectly specified str. Update the annotation to list[str] to match the actual return value. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/ltl2k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index 2c564cc937235..de765b8486bd1 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -71,7 +71,7 @@ class ltl2k(generator.Monitor): if not self.name: self.name =3D Path(file_path).stem =20 - def _fill_states(self) -> str: + def _fill_states(self) -> list[str]: buf =3D [ "enum ltl_buchi_state {", ] --=20 2.52.0 From nobody Sat Feb 7 18:21:00 2026 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 D8F26421F0C for ; Wed, 4 Feb 2026 14:56:42 +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=1770217003; cv=none; b=XFtyl40j965BA0TYnZM2UGZOcgDf+6hPCY8auss28S6ohnCNNPGRyEBiOu11jsnNRm2dwD+fGusYRkQk4Gd2xE6vziqi13jP2rPX4vKpVuDa0vOnOGDrBDU8Wu/nlCp5DM+7WVY5Ff4gfXEncYIJqgpgOib3Kf4ZlU920G+N0/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770217003; c=relaxed/simple; bh=DV+ljg4jPxQHDu6W3jpHwJ/SKvcrfpAyqxkIxDbiEGs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aLMXtbdhOpKJMWByLydvVcX8lbGWnIlUJ36bmbs2WbbOkkQCi5GoTE8S8ZyWuTkbTlYH3oklMRZI83fqRuYaRpP+5UZ4CHXmdHjDy4mF6/RKYLtFYyTZUas0z+6TmU3nIrG4pieymmxZ2HLe1l6QjVUWKo9UVYO7u955OCDju0s= 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=b2ASL/eX; 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="b2ASL/eX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770217002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BJYUJUBqACQiwbA6NS0AnI6UANj6h3zKYhThJ+2C8VI=; b=b2ASL/eXUv6W2/QywvTfnC6p6feVcODOd1r8vgIPJoCpi5+z1uIBCbygbBLqlRWEhiq0xa cM4bezQC2884M71/gPKYGwgU4KCjPOuQW4V0wA/LxsU5Dql8JJCxAB2/fiNYmTjBd9tEWQ AL3OqUE9eF4vhqovQWKY1C1udH90WfQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-CnhVrsWUMGWkAUZqzA5XXQ-1; Wed, 04 Feb 2026 09:56:35 -0500 X-MC-Unique: CnhVrsWUMGWkAUZqzA5XXQ-1 X-Mimecast-MFC-AGG-ID: CnhVrsWUMGWkAUZqzA5XXQ_1770216994 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BEAF6180034D; Wed, 4 Feb 2026 14:56:34 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 482D030001A5; Wed, 4 Feb 2026 14:56:32 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 20/20] rv/rvgen: add missing return type annotations Date: Wed, 4 Feb 2026 11:42:46 -0300 Message-ID: <20260204144914.104028-21-wander@redhat.com> In-Reply-To: <20260204144914.104028-1-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Add missing `-> str` return type annotations to code generation methods in RVGenerator. These methods return strings, and the missing hints caused errors with static analysis tools. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/generator.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index ef6c9150f50c6..4b984869a7b3d 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -73,13 +73,13 @@ class RVGenerator: return f"#include \n" return "" =20 - def fill_tracepoint_handlers_skel(self): + def fill_tracepoint_handlers_skel(self) -> str: return "NotImplemented" =20 - def fill_tracepoint_attach_probe(self): + def fill_tracepoint_attach_probe(self) -> str: return "NotImplemented" =20 - def fill_tracepoint_detach_helper(self): + def fill_tracepoint_detach_helper(self) -> str: return "NotImplemented" =20 def fill_main_c(self): @@ -100,19 +100,19 @@ class RVGenerator: =20 return main_c =20 - def fill_model_h(self): + def fill_model_h(self) -> str: return "NotImplemented" =20 - def fill_monitor_class_type(self): + def fill_monitor_class_type(self) -> str: return "NotImplemented" =20 - def fill_monitor_class(self): + def fill_monitor_class(self) -> str: return "NotImplemented" =20 - def fill_tracepoint_args_skel(self, tp_type): + def fill_tracepoint_args_skel(self, tp_type) -> str: return "NotImplemented" =20 - def fill_monitor_deps(self): + def fill_monitor_deps(self) -> str: buff =3D [] buff.append(" # XXX: add dependencies if there") if self.parent: --=20 2.52.0