From nobody Sun Feb 8 02:21:37 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 EDF57248867 for ; Mon, 19 Jan 2026 20:59:05 +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=1768856347; cv=none; b=esxcs46ug10HiEyn1BPddqziSbvkuwtA7k0VvZLBG/MNm2B+Z9/1X/XIx8k+xt7AFr0qQpEr1dpDevCTCZsQkJmZhQkS0o6agBtEGqKfHpumjt/vkqWyAUgClfVgEwtF6V5feZ47lN8laiRW92GE8Os1O80bHV/kMvQunrrKOl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856347; c=relaxed/simple; bh=QGcDYSWhPw0OsaIiT/Y79JYcZvgnZ1aoQ9w1dCfTLhM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lmqg8HZbbpV91oSbtoqEExwcIHI7byi3trqSZX+NgWCvEDTjJbOQD742BKFnYwqth6WWSCRRlDzKBJW0UdyH1OlIDH6SFWIpRRxVblSt2+LmBF92rHDSot5tGZxlNb00TKkWzYGFpe7EgIApDcpNTM+l/DDlEv0Sea4RHkQzgfU= 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=Fhy2oLii; 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="Fhy2oLii" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856344; 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=Yha+RfJYjyXBlkSkTQNuex11nXIbAhRh6al57WlRycU=; b=Fhy2oLii9o+JUznxXyFWwJE3YXWG0NFfF83qM4kQ+sLR9s/XZKYGOgt8OWLByBDZ3e4Ivm UBzybun+d/Rt+X1/qiXm2frikPFzqcBebz63LlYRr5Y7sdQF/KWvACYHgTRnGX5Jo7ckAz BUkn2YGSxGvsDooHM+/dh0KBI+eEEEg= 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-674-r816YAYpPQKmogDGZ0ExdA-1; Mon, 19 Jan 2026 15:59:02 -0500 X-MC-Unique: r816YAYpPQKmogDGZ0ExdA-1 X-Mimecast-MFC-AGG-ID: r816YAYpPQKmogDGZ0ExdA_1768856341 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 4522E1800378; Mon, 19 Jan 2026 20:59:01 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8F17419560AB; Mon, 19 Jan 2026 20:58:58 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 01/26] rv/rvgen: introduce AutomataError exception class Date: Mon, 19 Jan 2026 17:45:37 -0300 Message-ID: <20260119205601.105821-2-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Replace generic Exception usage with a custom AutomataError class that inherits from OSError throughout the rvgen tool. This change 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 inherits from OSError rather than Exception because most error conditions involve file I/O operations such as reading DOT files or handling file access issues. This semantic alignment makes exception handling more specific and appropriate. The exception is raised when DOT file processing fails due to invalid format, I/O errors, or malformed automaton definitions. Additionally, remove the broad try-except block from __main__.py that was catching all exceptions. This allows Python's default exception handling to provide complete stack traces, making debugging significantly easier by showing exact error types and locations. Signed-off-by: Wander Lairson Costa --- tools/verification/rvgen/__main__.py | 25 +++++++++------------ tools/verification/rvgen/rvgen/automata.py | 17 +++++++++----- tools/verification/rvgen/rvgen/dot2c.py | 4 ++-- tools/verification/rvgen/rvgen/generator.py | 7 ++---- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvge= n/__main__.py index fa6fc1f4de2f7..768b11a1e978b 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -39,22 +39,17 @@ if __name__ =3D=3D '__main__': =20 params =3D parser.parse_args() =20 - try: - if params.subcmd =3D=3D "monitor": - print("Opening and parsing the specification file %s" % params= .spec) - 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": - monitor =3D ltl2k(params.spec, params.monitor_type, vars(p= arams)) - else: - print("Unknown monitor class:", params.monitor_class) - sys.exit(1) + if params.subcmd =3D=3D "monitor": + print("Opening and parsing the specification file %s" % params.spe= c) + if params.monitor_class =3D=3D "da": + monitor =3D dot2k(params.spec, params.monitor_type, vars(param= s)) + elif params.monitor_class =3D=3D "ltl": + monitor =3D ltl2k(params.spec, params.monitor_type, vars(param= s)) else: - monitor =3D Container(vars(params)) - except Exception as e: - print('Error: '+ str(e)) - print("Sorry : :-(") - sys.exit(1) + print("Unknown monitor class:", params.monitor_class) + sys.exit(1) + else: + monitor =3D Container(vars(params)) =20 print("Writing the monitor into the directory %s" % monitor.name) monitor.print_files() diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index d9a3fe2b74bf2..8d88c3b65d00d 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(OSError): + """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 b9b6f14cc536a..1a1770e7f20c0 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 "" @@ -93,7 +93,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 Sun Feb 8 02:21:37 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 CA3FD2F0C7A for ; Mon, 19 Jan 2026 20:59:32 +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=1768856374; cv=none; b=OIbuOx+DoE9BQLhPFKvCvnDB2CMykWjhwj+4RZKxkRORG+eSDjpi/YvzgX/m26TKrE9DchPAn+2iA5wUH92iXXvx4Dwt1KhhdS/z9zB+6Wp/0FnvAIDuZG21ICvMvq4ghzQyZ1s/XNxPUwbJtbzMXiDOzlMBS4rOHrfZq3VaFLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856374; c=relaxed/simple; bh=40ZPEGMN0sob0b5iK6GGaA2xvJRMYv29Ms5s8ro22F0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rz+1ZZTT3YvumFARlNgAxGv8BFQ2R8f4rt9czvhq/gVOgWge84Rekpt9fiYluJVeIxMRezo45ofzW8xs3GtoTLdbe8phuWlHogb1Rlv3sWsslZjAT3LU0cxNULABoHvLxen2H1+a4sCoBz9HAZJZBqHzwafLGZyIbXStFCDbuUs= 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=Z7GM4FPO; 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="Z7GM4FPO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856371; 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=PfhqJrr+RjCAEt1YCTrD+2mUFPkkTKYcoUT83FMXRFs=; b=Z7GM4FPO6q4V0yX4NjsUVehGRAQYRRS+BZ2xHlxkpi1SasnmR0rur+moSdSHqW4LEH+l5Q mJ35jREYP5gsJCPvthCIIlqzb1Wbn8yegQs6jSTtQy7VNGY3C23Y9ugck7upFxzAQ1hz4V g30HqIKNtry3Dnxylq/mPjTR/FOJGfw= 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-120-wDgUvgwfMI2Al32Fs_H9AQ-1; Mon, 19 Jan 2026 15:59:26 -0500 X-MC-Unique: wDgUvgwfMI2Al32Fs_H9AQ-1 X-Mimecast-MFC-AGG-ID: wDgUvgwfMI2Al32Fs_H9AQ_1768856365 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A0A7019560A1; Mon, 19 Jan 2026 20:59:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E4E019560AB; Mon, 19 Jan 2026 20:59:22 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 02/26] rv/rvgen: remove bare except clauses in generator Date: Mon, 19 Jan 2026 17:45:38 -0300 Message-ID: <20260119205601.105821-3-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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: Gabriele Monaco Reviewed-by: Nam Cao --- 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 Sun Feb 8 02:21:37 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 0549F248867 for ; Mon, 19 Jan 2026 20:59:53 +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=1768856396; cv=none; b=sX9ub+Jd6gXhH0uBXNCIvsDlfdtzXlwYwDsmVlfnHriXRrGyBn3HbP5FF003iKJPUhCgQ0PdcL7XQdw8hJuFy9aftf4MLsb+vzammT8xO4tzeCmVUPxQQIqLUJ6mLNc2S0rK3v/qHA7Hmx/mF40Wuz5JoKt80AznyPKYTRsS5IA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856396; c=relaxed/simple; bh=Ef3V9U3KkJbH7Tsrqg0l+WydrWklOLdphNqtVGBOZtY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AraRK1oP5HQQXW9t2vTcB/5UUKzookUbJBfncTClP+UaHpExgRcSSpPCKwj0bmG6c/pmSYUXlYDKg8oofFdrVdVFiwho7hImJOuPWzhTmnS19pKP/KSJtAlCEdJ+mUjjF5roj8w5rs9hPoUS8yVemQtj6SfqpTwShzyZe+2PeRw= 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=HhMJv9C1; 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="HhMJv9C1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856393; 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=yj89ReA7SC9wjYbuj/WC8bJ+s1gi/80kfHSLMsU4EBw=; b=HhMJv9C1ONbyrIBZosbIFq7UCVakogzu8XK/8dWyhpqv4OPyz3BkQ7Rmw0idKTQfeUdhre +uzRFsmwG2MTVB3YgSguzWlGM6vSxwI8DMX/Nu5H5k4o+3WKSMHQl4orX19vA5HoLlk21l CmFoHp9xvf63tPbPfwc4DxDYNw7bqGE= 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-580-fcciGlGNOFKUoa7JXaWnJw-1; Mon, 19 Jan 2026 15:59:51 -0500 X-MC-Unique: fcciGlGNOFKUoa7JXaWnJw-1 X-Mimecast-MFC-AGG-ID: fcciGlGNOFKUoa7JXaWnJw_1768856390 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 9B40818005AF; Mon, 19 Jan 2026 20:59:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D032F19560AB; Mon, 19 Jan 2026 20:59:47 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 03/26] rv/rvgen: replace % string formatting with f-strings Date: Mon, 19 Jan 2026 17:45:39 -0300 Message-ID: <20260119205601.105821-4-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/__main__.py | 6 +-- tools/verification/rvgen/rvgen/automata.py | 6 +-- tools/verification/rvgen/rvgen/dot2c.py | 40 +++++++------- tools/verification/rvgen/rvgen/dot2k.py | 26 ++++----- tools/verification/rvgen/rvgen/generator.py | 59 ++++++++++----------- tools/verification/rvgen/rvgen/ltl2k.py | 30 +++++------ 6 files changed, 82 insertions(+), 85 deletions(-) diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvge= n/__main__.py index 768b11a1e978b..eeeccf81d4b90 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -40,7 +40,7 @@ if __name__ =3D=3D '__main__': params =3D parser.parse_args() =20 if params.subcmd =3D=3D "monitor": - print("Opening and parsing the specification file %s" % params.spe= c) + print(f"Opening and parsing the specification file {params.spec}") if params.monitor_class =3D=3D "da": monitor =3D dot2k(params.spec, params.monitor_type, vars(param= s)) elif params.monitor_class =3D=3D "ltl": @@ -51,11 +51,11 @@ if __name__ =3D=3D '__main__': else: monitor =3D Container(vars(params)) =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 8d88c3b65d00d..3e24313a2eaec 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 1a1770e7f20c0..78959d345c26e 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -37,11 +37,11 @@ class Dot2c(Automata): =20 def __get_enum_states_content(self): buff =3D [] - buff.append("\t%s%s =3D 0," % (self.initial_state, self.enum_suffi= x)) + buff.append(f"\t{self.initial_state}{self.enum_suffix} =3D 0,") 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 @@ -51,7 +51,7 @@ class Dot2c(Automata): =20 def format_states_enum(self): buff =3D [] - buff.append("enum %s {" % self.enum_states_def) + buff.append(f"enum {self.enum_states_def} {{") buff.append(self.get_enum_states_string()) buff.append("};\n") =20 @@ -62,12 +62,12 @@ class Dot2c(Automata): first =3D True for event in self.events: if first: - buff.append("\t%s%s =3D 0," % (event, self.enum_suffix)) + buff.append(f"\t{event}{self.enum_suffix} =3D 0,") first =3D False else: - 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 @@ -77,7 +77,7 @@ class Dot2c(Automata): =20 def format_events_enum(self): buff =3D [] - buff.append("enum %s {" % self.enum_events_def) + buff.append(f"enum {self.enum_events_def} {{") buff.append(self.get_enum_events_string()) buff.append("};\n") =20 @@ -93,25 +93,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): 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): 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, buff): @@ -169,9 +169,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: @@ -215,7 +215,7 @@ class Dot2c(Automata): =20 def format_aut_init_final_states(self): 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 @@ -231,7 +231,7 @@ class Dot2c(Automata): =20 def format_invalid_state(self): 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 ed0a3c9011069..1c0d0235bdf62 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): return self.monitor_type.upper() @@ -27,7 +27,7 @@ class dot2k(Monitor, Dot2c): def fill_tracepoint_handlers_skel(self): 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_%s(p, %s%s);" % (handle, self.name, e= vent, self.enum_suffix)); + buff.append(f"\tda_{handle}_{self.name}(p, {event}{self.en= um_suffix});"); else: - buff.append("\tda_%s_%s(%s%s);" % (handle, self.name, even= t, self.enum_suffix)); + buff.append(f"\tda_{handle}_{self.name}({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): 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): 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): 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(" */") @@ -73,10 +73,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() @@ -111,8 +111,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): 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 Sun Feb 8 02:21:37 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 1DFEE2F744A for ; Mon, 19 Jan 2026 21:00:20 +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=1768856422; cv=none; b=JlaX+wyt6W4ghWE9t2As+151tzCe3uQIA0mxLUw79L0aZ7a73sPFyybYmq2iiJMr5G/Nb8OiGENuftTgHmZLaK/bKMLtLUK3skqX4pQCXi9zdaBIsVLbHdrqsQXuOc8ptA0Idca+d0IZ1UIg+mCv+LZN4x1eC6B2IHHjkFdZTWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856422; c=relaxed/simple; bh=ywRHrFoq3RI/gRX/tSJBRYTnKKZls7HdKmG7OnKNVxI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KFs2PX91VQRVeeYitUTpv+TQe900Yzb3fZm0R7a+LJ7UimS1goKvpcZO06YgDQNm0TZobdKMHrCH4j3jo/fs+e+B0WlStnHQutmCj50p0KZomff1xq7aZUIjMmnuYoP9eHDaavxlNx6pW5o3qzvOzW3hmSalc4z+2qcH/z8VXFo= 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=CMPERq0e; 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="CMPERq0e" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856420; 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=OqZNHfK8rT/x/qoAGa3l0nqLH4uXBfgeiwASt0ZjNik=; b=CMPERq0eCMMCPlQYC7E8IhTpfzesTFs4ahwOwOQYOZVC7Q/HQf4fjnSpX8s+mc1IHmBizn z2qEjdMaWiFAB0sr9e7MUfFy2xFTntxp34VGmu+Kl6j9Z2bnfzTXr313UBJyGCzAPDBEkM a8YhmAPfU5tN905HjtVHuCSEnMjtINA= 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-554-GmLDgP4sOJ6yG5jByqA7iw-1; Mon, 19 Jan 2026 16:00:16 -0500 X-MC-Unique: GmLDgP4sOJ6yG5jByqA7iw-1 X-Mimecast-MFC-AGG-ID: GmLDgP4sOJ6yG5jByqA7iw_1768856415 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 AFA2D18002C8; Mon, 19 Jan 2026 21:00:15 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 65E9919560AB; Mon, 19 Jan 2026 21:00:12 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 04/26] rv/rvgen: replace __len__() calls with len() Date: Mon, 19 Jan 2026 17:45:40 -0300 Message-ID: <20260119205601.105821-5-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 3e24313a2eaec..ed02d0c69b410 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 78959d345c26e..0fb3617ad8ce9 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -86,14 +86,14 @@ class Dot2c(Automata): def get_minimun_type(self): 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 @@ -149,12 +149,12 @@ class Dot2c(Automata): return buff =20 def __get_max_strlen_of_states(self): - 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): - 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 Sun Feb 8 02:21:37 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 99A502F7478 for ; Mon, 19 Jan 2026 21:00:45 +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=1768856447; cv=none; b=FF33t7vXdv/4YUBpNiSaNzFk5dEmscHsuBUVzIWHxWjJL0+qeE2XwcIEAzNZB8dKU1DuX2WsC7dEAO7pBLIg7xszBWNflmn76sqBg9NywEXzTHAlTiF4j1pXb4liNveWk0emAMgZBdXVhUA2Qt8yz6Nm6/zTCpWcCb4bm0Z8JjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856447; c=relaxed/simple; bh=8DkqGNezhZS+jns6pl7LkC98k3QrxCSUlXLi95NECOc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OSaaSFx6vD1Yyu5G0+cDLfNWgVDlVUyL30/xn5P6CG76izhrtGijOzPSJNMYmaQ2tWoXLXRJIgpkDczvWdau3q/Mg+JDNYfwWvq7tbI0jtJ0bArarlwzRPo4550b+asLHtTFsTOryxmckA0yX8C8+xROPnCqGbw2/lWHQmn0ewY= 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=dG0FFSlY; 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="dG0FFSlY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856444; 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=PDv8xxnb+/FccRewmtuSoSQQbd73qMaYdppoDFSJu5Y=; b=dG0FFSlY75zqM0UxYxM8yEHqV+bRNNmJUaJAzgTbquXCRsQeJaQCLbPTaXcZ+JjwGaRp9z aKCChcRxxIECPKf890QnIG5C1WJN+DVCHvSaax5NDkHjJ2MelIJptfPauHwR+UuK5mXhbE 4MzymuVW0P5dNOemCweG+cqezC03bGo= 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-587-xnge12KDOD-KRF_wthjfQg-1; Mon, 19 Jan 2026 16:00:41 -0500 X-MC-Unique: xnge12KDOD-KRF_wthjfQg-1 X-Mimecast-MFC-AGG-ID: xnge12KDOD-KRF_wthjfQg_1768856440 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 27F421800473; Mon, 19 Jan 2026 21:00:40 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9FF6E19560AB; Mon, 19 Jan 2026 21:00:37 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 05/26] rv/rvgen: remove unnecessary semicolons Date: Mon, 19 Jan 2026 17:45:41 -0300 Message-ID: <20260119205601.105821-6-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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. The changes affect four instances across two files. In dot2c.py, one semicolon is removed from a boolean assignment. In dot2k.py, three semicolons are removed from string append operations that build generated C code. Note that the semicolons inside the string literals themselves are correctly preserved as they are part of the C code being generated, not Python syntax. 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: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/dot2c.py | 2 +- tools/verification/rvgen/rvgen/dot2k.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index 0fb3617ad8ce9..b9a2c009a9246 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -120,7 +120,7 @@ class Dot2c(Automata): for entry in buff: if first: string =3D string + "\t\t\"" + entry - first =3D False; + first =3D False else: string =3D string + "\",\n\t\t\"" + entry string =3D string + "\"" diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index 1c0d0235bdf62..291385adb2c20 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}_{self.name}(p, {event}{self.en= um_suffix});"); + buff.append("\tstruct task_struct *p =3D /* XXX: how do I = get p? */;") + buff.append(f"\tda_{handle}_{self.name}(p, {event}{self.en= um_suffix});") else: - buff.append(f"\tda_{handle}_{self.name}({event}{self.enum_= suffix});"); + buff.append(f"\tda_{handle}_{self.name}({event}{self.enum_= suffix});") buff.append("}") buff.append("") return '\n'.join(buff) --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 2545B257825 for ; Mon, 19 Jan 2026 21:01:09 +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=1768856471; cv=none; b=Xv2t083kRaj6o8H6kw9kc4C5dw++oCXABtlv89c33BLTOcM3Insu+Uyks9mKOEBn4xTE1SA8lIHxjw01kgrzwArLgpz+9O3VZNvIMB9rcOScrmcgTwh36BaKVV8PN4DBp1IYIlZnEUWc7buqQU7FaAdl5m0+n+pEroLwtGQkHbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856471; c=relaxed/simple; bh=g9BPMUDl9MALnH9nqEO1jSn+BilUvvqSL5IohiW4+nU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sXW/p3WFzaIo8MP8itmJYAravMUfybfvD9R0rfABG6vuBJOJgHcp0rXEkzrAu7fAQIyJBPAjm9w6XW8NRBgX1at9Rj1MD3J1pXJmCjtpKKaKrsTzSVH4ZhZvBSnv7AugFsfj514G0bt4n7hkSoGnyctd10fFz+BULegzCRA9xiE= 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=d6y9AxL2; 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="d6y9AxL2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856469; 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=Ye4ehv+3Lnra9b7oS7d0s1JmOqih58blGer/Fk7p2Ac=; b=d6y9AxL2/d60tt513zZ5OtneqprZj4mmW0GG7jZKh763eZnjsUfuuCoShUM3inzhvlgHhJ cRcEzDxQoxX/Gu+u8FNEHoQrjZmh68wBKhoVihNH0RLdisS1k18uezj+OsYIsIaU8cI6J4 OPKt9uUt0sMQSge33KqHUIIkJFNHdV8= 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-592-oyU2ygxxN9qEGQOit94WVw-1; Mon, 19 Jan 2026 16:01:05 -0500 X-MC-Unique: oyU2ygxxN9qEGQOit94WVw-1 X-Mimecast-MFC-AGG-ID: oyU2ygxxN9qEGQOit94WVw_1768856464 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 AEB9C1800447; Mon, 19 Jan 2026 21:01:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 33F7A1955F43; Mon, 19 Jan 2026 21:01:01 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 06/26] rv/rvgen: use context managers for file operations Date: Mon, 19 Jan 2026 17:45:42 -0300 Message-ID: <20260119205601.105821-7-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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: Gabriele Monaco Reviewed-by: Nam Cao --- 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 ed02d0c69b410..70ff98abea751 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 Sun Feb 8 02:21:37 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 E379D231C91 for ; Mon, 19 Jan 2026 21:01:34 +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=1768856496; cv=none; b=lTuMSn65QCr8h9xlSVxSf4oBORIvlSg4wp032/lfLfX6OriHq4vshmG585qx6/F+8oxX0rVGIwgQCxoc8QhvXa6BcBcGukgQB2SfG+z0mFq9r5DdvL1GbbzSgEv6r28Vt8axp+Ov31qm/niTO41IV6j5DWbaKyhd7mI3P/z9+OY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856496; c=relaxed/simple; bh=pW65pJ3HZRQGJKGr2pCi9tYX8rTKrrz+q8humsAMrA0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JYdhMS8eKiGQQ7o+eB+DACzlwmUNrs9zbwb2nLXVkKzaaVn8mgZ6+jI3lyHaAe9VuQxn743NtnCcVfLOGF0fvyDsKZf6P/lfTUrUSW7U8fMp/2ewJUBMAFiw2bf7pk8JD61fGwLxJiUO4Q8/s93vkQaSdkuu6IlT9KayVPX7MXs= 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=PYaNkPDD; 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="PYaNkPDD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856493; 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=XERC8Z3HUdi/lg0y+Jk/anNqkNoun9YsdNJdLNhv39g=; b=PYaNkPDDPfFI9zGrkmZIAETbRdo6sFrdLensovEV0Zv/x2OZgOE7jc6JgNAUTjFuqO9QP3 dJCWtMlXo0NW3WMGcliBPdAiH6Tl0X2+sy6zblviYmfFBxk3XY4DU6VlembZfX2rNrJX1Z 6Zf4LT5wBZ9/qi62Q81Qg7ADHMKUiQo= 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-136-P9elRolsMQyGYWDwqm3Jxw-1; Mon, 19 Jan 2026 16:01:30 -0500 X-MC-Unique: P9elRolsMQyGYWDwqm3Jxw-1 X-Mimecast-MFC-AGG-ID: P9elRolsMQyGYWDwqm3Jxw_1768856489 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 545A71800378; Mon, 19 Jan 2026 21:01:29 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80BF619560AB; Mon, 19 Jan 2026 21:01:26 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 07/26] rv/rvgen: replace __contains__() with in operator Date: Mon, 19 Jan 2026 17:45:43 -0300 Message-ID: <20260119205601.105821-8-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Replace the direct call to the __contains__() dunder method with the idiomatic in operator in the dot2c module. The previous implementation explicitly called the __contains__() method to check for membership in the final_states collection, which is not the recommended Python style. Python provides the in operator as the proper way to test membership, which internally calls the __contains__() method. Directly calling dunder methods bypasses Python's abstraction layer and reduces code readability. Using the in operator makes the code more natural and familiar to Python developers while maintaining identical functionality. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/dot2c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index b9a2c009a9246..c97bb9466af6d 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -207,7 +207,7 @@ class Dot2c(Automata): else: first =3D False =20 - if self.final_states.__contains__(state): + if state in self.final_states: line =3D line + '1' else: line =3D line + '0' --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 A1E59257825 for ; Mon, 19 Jan 2026 21:01:58 +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=1768856520; cv=none; b=pTHcq/RJLqSW46pZlTUjSzwG3CJ4THpRWr+cAOtW975nCguj+Q5SE98OWmqTUhz6I3AN+9RohR72I0U+8Q34jrR4m3J8Wgi6hL7NO8MHJxJyoscAgSZM7FwnmUyaPZp+5S8sssyjELvxAHXelS60Zgb+PhJWc6pgrsF7e0tJGB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856520; c=relaxed/simple; bh=wCKv6i46VQo8RzJYs6rWEhK41I7MDPwLrrLLY3O/SZM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eOf5SCuvDixtqG5NfG+HD+UX+LpC4xu6olLsve7FqTtaOcKSf6gPx98jhMf0GGN91M0nlvGQDe+H1PNJu18cSsY6k1rQ290IqPff33VxnQWS5g78LpaKO/fZUe6YBVJ04uVG2iine2/Zm74bx5FYf7DkbGWs4OC3LtTcaduSuh4= 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=iR7aGWYz; 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="iR7aGWYz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856517; 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=JAD9YBzMW3eH6RwLMXXyDtAG2c4/YXRh5uCCHihgJCY=; b=iR7aGWYzMf8rK8S9+o7uc4IK3vEZNxuVErA18cgjS2h6NgkUosV4U8nouoS6tpf8Hm/VaR EcsxZ+tBjTuFKs5Ibf+/UMTo/11BTRE9tmSwX7LME2lA0NU9HIKuEW56BD8f+XoiQ+kpm1 hrHJfr2pP0Mvp8sxIKmi1X1zFm2g9VQ= 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-634-EOWiOGirNuKtyZrakNyJCw-1; Mon, 19 Jan 2026 16:01:54 -0500 X-MC-Unique: EOWiOGirNuKtyZrakNyJCw-1 X-Mimecast-MFC-AGG-ID: EOWiOGirNuKtyZrakNyJCw_1768856513 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A0F6A1956094; Mon, 19 Jan 2026 21:01:53 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2476719560AB; Mon, 19 Jan 2026 21:01:50 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 08/26] rv/rvgen: simplify boolean comparison Date: Mon, 19 Jan 2026 17:45:44 -0300 Message-ID: <20260119205601.105821-9-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Replace explicit boolean comparison with truthiness test in the dot2c module. The previous implementation used the redundant pattern of comparing a boolean variable directly to False, which is not idiomatic Python and adds unnecessary verbosity to the code. Python's truthiness allows for more concise and readable boolean checks. The expression "if not first" is clearer and more Pythonic than "if first =3D=3D False" while maintaining identical semantics. This pattern is preferred in PEP 8 and is the standard approach in the Python community. This change continues the ongoing code quality improvements to align the codebase with modern Python best practices. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/dot2c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/r= vgen/rvgen/dot2c.py index c97bb9466af6d..fa9e9ae16640f 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -202,7 +202,7 @@ class Dot2c(Automata): line =3D "" first =3D True for state in self.states: - if first =3D=3D False: + if not first: line =3D line + ', ' else: first =3D False --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 A516C25B1C7 for ; Mon, 19 Jan 2026 21:02:23 +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=1768856545; cv=none; b=fOs/CNSEfy8Y2sybmVE8g1ETiiZLti5DZFfli/OznPCWLi/SY5SN+u09wdxQAX05T2YI1qVLRUjd1U78LjcOXJv1T1/UvmA3g5HGzi3tZ4hBZjKKoCBQ7r5kwxQVeHy41freLiRbd4y6oDsdQ2EBgu7VC9msb97K2ya8sYZfrHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856545; c=relaxed/simple; bh=3HxFQxxM6vktqQVICPtcfplyEe4QMmkt2BlQS319ws8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i1dVPUOH7Z+wGcaVqATBENQSZyvI/1Y0kfxEgB8D9Pqb9V1uJ3IooOxX838pCz0lK54ktcm2qJJIRq8XT2+Yf0wpgZJrl4RlWWhAOEGMxUoS9ZIs5H9HNpQdswoGJ3wDkfwYxMi2Gu1RJgSIDGw9lmcSN3ZFdrF1kmFP5ukCFKo= 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=SBSwNL7L; 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="SBSwNL7L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856542; 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=QclBMzOHMQQ11XlfMLU94W1QkzKCUIDDZpVOzdcTRns=; b=SBSwNL7LuwhhkeBtDjou0NwAO/uWk+08dhbgCYh+H+pvd+c586uOHG6bxb+WNiPS9xehSU VIpy9cgsWNDZRfW2pLdiJQR6KHYCxmjAkP0V8YAU50l0Bu2Tf34mPOC/ts5gA/dYykICG6 cndvrWJLpcJv7JjLGQF8rr3qE8IVpYs= 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-693-1mJTTBGFPGqHDCraGtk9DQ-1; Mon, 19 Jan 2026 16:02:19 -0500 X-MC-Unique: 1mJTTBGFPGqHDCraGtk9DQ-1 X-Mimecast-MFC-AGG-ID: 1mJTTBGFPGqHDCraGtk9DQ_1768856538 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 6BD18195609E; Mon, 19 Jan 2026 21:02:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E328619560AB; Mon, 19 Jan 2026 21:02:15 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 09/26] rv/rvgen: replace inline NotImplemented with decorator Date: Mon, 19 Jan 2026 17:45:45 -0300 Message-ID: <20260119205601.105821-10-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Replace inline NotImplementedError raises with a dedicated decorator in the ltl2ba module. The previous implementation used explicit raise statements inside abstract method bodies for BinaryOp and UnaryOp classes, which required maintaining identical boilerplate across seven different methods that need to be overridden by subclasses. All stub methods in generator.py have been converted from returning strings to using the decorator with ellipsis function bodies, which is the recommended Python style for marking incomplete interface methods. This ensures that any attempt to use unimplemented functionality fails fast with a clear exception rather than silently propagating string values through the code. The new @not_implemented decorator consolidates this pattern into a single reusable definition that clearly marks abstract methods while reducing code duplication. The decorator creates a wrapper that raises NotImplementedError with the function name, providing the same runtime behavior with improved maintainability. Method bodies now use the ellipsis literal instead of pass statements, which is the preferred Python convention for stub methods according to PEP 8. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/generator.py | 29 +++++++++-------- tools/verification/rvgen/rvgen/ltl2ba.py | 25 ++++++++------ tools/verification/rvgen/rvgen/utils.py | 36 +++++++++++++++++++++ 3 files changed, 66 insertions(+), 24 deletions(-) create mode 100644 tools/verification/rvgen/rvgen/utils.py diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index ee75e111feef1..fc9be5f6aaa1f 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -7,6 +7,7 @@ =20 import platform import os +from .utils import not_implemented =20 =20 class RVGenerator: @@ -73,14 +74,14 @@ class RVGenerator: return f"#include \n" return "" =20 - def fill_tracepoint_handlers_skel(self): - return "NotImplemented" + @not_implemented + def fill_tracepoint_handlers_skel(self): ... =20 - def fill_tracepoint_attach_probe(self): - return "NotImplemented" + @not_implemented + def fill_tracepoint_attach_probe(self): ... =20 - def fill_tracepoint_detach_helper(self): - return "NotImplemented" + @not_implemented + def fill_tracepoint_detach_helper(self): ... =20 def fill_main_c(self): main_c =3D self.main_c @@ -100,17 +101,17 @@ class RVGenerator: =20 return main_c =20 - def fill_model_h(self): - return "NotImplemented" + @not_implemented + def fill_model_h(self): ... =20 - def fill_monitor_class_type(self): - return "NotImplemented" + @not_implemented + def fill_monitor_class_type(self): ... =20 - def fill_monitor_class(self): - return "NotImplemented" + @not_implemented + def fill_monitor_class(self): ... =20 - def fill_tracepoint_args_skel(self, tp_type): - return "NotImplemented" + @not_implemented + def fill_tracepoint_args_skel(self, tp_type): ... =20 def fill_monitor_deps(self): buff =3D [] diff --git a/tools/verification/rvgen/rvgen/ltl2ba.py b/tools/verification/= rvgen/rvgen/ltl2ba.py index f14e6760ac3db..9a3fb7c5f4f65 100644 --- a/tools/verification/rvgen/rvgen/ltl2ba.py +++ b/tools/verification/rvgen/rvgen/ltl2ba.py @@ -9,6 +9,7 @@ =20 from ply.lex import lex from ply.yacc import yacc +from .utils import not_implemented =20 # Grammar: # ltl ::=3D opd | ( ltl ) | ltl binop ltl | unop ltl @@ -150,14 +151,14 @@ class BinaryOp: yield from self.left yield from self.right =20 - def normalize(self): - raise NotImplementedError + @not_implemented + def normalize(self): ... =20 - def negate(self): - raise NotImplementedError + @not_implemented + def negate(self): ... =20 - def _is_temporal(self): - raise NotImplementedError + @not_implemented + def _is_temporal(self): ... =20 def is_temporal(self): if self.left.op.is_temporal(): @@ -167,8 +168,9 @@ class BinaryOp: return self._is_temporal() =20 @staticmethod + @not_implemented def expand(n: ASTNode, node: GraphNode, node_set) -> set[GraphNode]: - raise NotImplementedError + ... =20 class AndOp(BinaryOp): op_str =3D '&&' @@ -288,19 +290,22 @@ class UnaryOp: def __hash__(self): return hash(self.child) =20 + @not_implemented def normalize(self): - raise NotImplementedError + ... =20 + @not_implemented def _is_temporal(self): - raise NotImplementedError + ... =20 def is_temporal(self): if self.child.op.is_temporal(): return True return self._is_temporal() =20 + @not_implemented def negate(self): - raise NotImplementedError + ... =20 class EventuallyOp(UnaryOp): def __str__(self): diff --git a/tools/verification/rvgen/rvgen/utils.py b/tools/verification/r= vgen/rvgen/utils.py new file mode 100644 index 0000000000000..e09c943693edf --- /dev/null +++ b/tools/verification/rvgen/rvgen/utils.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only + + +def not_implemented(func): + """ + Decorator to mark functions as not yet implemented. + + This decorator wraps a function and raises a NotImplementedError when = the + function is called, rather than executing the function body. This is u= seful + for defining interface methods or placeholder functions that need to be + implemented later. + + Args: + func: The function to be wrapped. + + Returns: + A wrapper function that raises NotImplementedError when called. + + Raises: + NotImplementedError: Always raised when the decorated function is = called. + The exception includes the function name and any arguments tha= t were + passed to the function. + + Example: + @not_implemented + def future_feature(arg1, arg2): + pass + + # Calling future_feature will raise: + # NotImplementedError('future_feature', arg1_value, arg2_value) + """ + def inner(*args, **kwargs): + raise NotImplementedError(func.__name__, *args, **kwargs) + + return inner --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 EF6C250096D for ; Mon, 19 Jan 2026 21:02: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=1768856571; cv=none; b=aZu6Uavj+bdWNan+gHxu6PH1tApPurjX9Fvl6ZcKIgYHFgO96VUPZUzeywto+nHRCGo6RSqnpl0VSt+ByP7se18c3/5uZAS/NVCQVWxNkMNFqBrWaezi/0LKtU/+WaihP6dRMyMNP2w9WhHctrjLDSdZhovaCDa1P6YjCL1RbG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856571; c=relaxed/simple; bh=MWKRrN0Rehb4ipv99vA6QFypK3/oOBFrT3rJbmagcRw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oyRNoRI9BilHG77k4jpPRODhIYlZUlp4uB3hLGEUfypNKHLMr+Es8sAI14aw9UOlfI0Cy4QZ76mShZX0uiWsRHKd83THbo1L12S9Fn285dZYqd50KNMaerAo/clj4i7yhXaAd82pHa1hiLNI+r0LkmhSkVJmTslFCn7pw7J3aeA= 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=E5G4yDPh; 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="E5G4yDPh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856569; 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=KSwc3LNix1F915NPLbGd4d4ei3SN/jCoSbkqD7jEgyY=; b=E5G4yDPhf5gvMm7w+DylTFoHpOEqpwtQ54KONmp0xeLJmLe4KEdYgvEVlCKcOA5/5DagbD LYFJMeCKkU4ChwQ2GC/FJfH0lnSAln64Qm/ogW9oiHwfrt8qofk6T046v+mpd/sH20QXMb p6p1FpEpnoghG33L+to+SVLdR+utI+M= 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-658-XNpoyFmMNOOdM6c9gkUMKw-1; Mon, 19 Jan 2026 16:02:44 -0500 X-MC-Unique: XNpoyFmMNOOdM6c9gkUMKw-1 X-Mimecast-MFC-AGG-ID: XNpoyFmMNOOdM6c9gkUMKw_1768856563 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 E70E91956088; Mon, 19 Jan 2026 21:02:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C18A19560AB; Mon, 19 Jan 2026 21:02:40 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 10/26] rv/rvgen: fix typos in automata docstring and comments Date: Mon, 19 Jan 2026 17:45:46 -0300 Message-ID: <20260119205601.105821-11-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Fix two typos in the Automata class documentation that have been present since the initial implementation. The class docstring incorrectly stated "part it" instead of "parses it" when describing how the class processes DOT files. 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". Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/automata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 70ff98abea751..c0c8d13030007 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -18,7 +18,7 @@ class AutomataError(OSError): """ =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 --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 85B3029D288 for ; Mon, 19 Jan 2026 21:03: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=1768856594; cv=none; b=YBXbn00xkLWY1DFvFzIyBPG6Uc+oUbxymirNwAlScvJwCm6Oz9dPBdvf5KL49vuJxzko+K8HvkniArTY4zhsfHpdJOagyA//+a//PFV9JsK6XRwI4Xl9SRNva/PCaCbhPds/bHCBEUmqiUaoo112pcx6OPyDay8zRKffK6v7Lcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856594; c=relaxed/simple; bh=Jv5+K98VizUM1mXRwDMUfBAd5yY4osV4n8dduP0Gjzw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VtVDMX1QmMdkmIBR/RlPqtLsVzzvUkqiOHpKXgQest7w2WHEn07xlLkF+lUGH34rzkaL9QjaF3ZBTRnu6sNgKCaqMi8bfs3pT31xHsghX+vmzumeuo7W1coIxxuqVfUTAukghmletNi57n5UoHNgytPoRCULgPNlwLNak4fQEQQ= 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=BbWv4LnY; 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="BbWv4LnY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856589; 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=ZA8TdjTDpZCZzwuKRz2gWQ7ez/p2MAQq/3Y4NoDfsuY=; b=BbWv4LnYZP61pZGyZAgpFOkRlbk2ew2PXDlyn2tRz1uM2zW05ZaSR8i5YItLuYpeOoGxqA knIYJphJhDCkOMIUx+neJDCJPXhpjBKPLg3Fw6zR5gjfDQjBLCh5qhhWjgxoKdiCXT2K9P v7ZE4bOOqVM6meFW3DDYoc/oqAkLIC8= 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-230-GKvFdqt8N6isZNQ9JeaeMQ-1; Mon, 19 Jan 2026 16:03:08 -0500 X-MC-Unique: GKvFdqt8N6isZNQ9JeaeMQ-1 X-Mimecast-MFC-AGG-ID: GKvFdqt8N6isZNQ9JeaeMQ_1768856587 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 4A778195609F; Mon, 19 Jan 2026 21:03:07 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BB92819560AB; Mon, 19 Jan 2026 21:03:04 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 11/26] rv/rvgen: fix typo in generator module docstring Date: Mon, 19 Jan 2026 17:45:47 -0300 Message-ID: <20260119205601.105821-12-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Fix typo in the module docstring: "Abtract" should be "Abstract". Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index fc9be5f6aaa1f..ea1fa0f5d818d 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 Sun Feb 8 02:21:37 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 7C96B257825 for ; Mon, 19 Jan 2026 21:03:36 +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=1768856617; cv=none; b=j9VCHiIBar3mhjYn1lzyPMYgi+VspdnTCLMjwkKzq39PhBox5R46aJAm7pSQDQHZwL0/RBFuMWe+5POUzEyqzyFllOFg3CGyXXFFmSUg3OgKUBhhhoKr69pzQv1YYpo5uVDQUqJnOnHDCnvAGX1a6mGKA019sEXOA0Zcb28RX5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856617; c=relaxed/simple; bh=Wee6i9AoESUMRTZTBQPlOjKVEuX4WYstZGjIBx1Vdto=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aH2XdcFJz6Fs1nabUSrMEMNXSvCJ8nrFH2IY0cCf0FEWWIeALmX8HWUTVb6WmGxbxWObdYiW8YfLlX2fIcaDDAA2kd34ZoIR2S+8wwLXewSvDQpUJIu5DT/BwIstgaA4DlHpaR1BrZ6L3NAzNXmGgA3Q0gegQ837Z0f+ke+wpis= 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=iXfWc26n; 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="iXfWc26n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856615; 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=ND9bvL6OiKftrWzmoh8F3v2WLvVwAgqURX1kym+kooo=; b=iXfWc26n0Jy8bp6yG6CIrPoRNcxE9HT/0QQVdEG1Dwu62TvkHDb1CglkZIfQUckInB8jr/ IRG/6VsgFad7fzav2ZsyHzx3JvHwBpnujdU/UBDh5CAFUxj0FXA4vSNukXcMR32fyHd4ym +xNE4OEYmbWl6oOA6AYUDlW0rRZ3AKM= 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-589-QtX2Y7igMlen9r8jT8QoLw-1; Mon, 19 Jan 2026 16:03:32 -0500 X-MC-Unique: QtX2Y7igMlen9r8jT8QoLw-1 X-Mimecast-MFC-AGG-ID: QtX2Y7igMlen9r8jT8QoLw_1768856611 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 8801319560B5; Mon, 19 Jan 2026 21:03:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0DC3619560AB; Mon, 19 Jan 2026 21:03:28 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 12/26] rv/rvgen: fix PEP 8 whitespace violations Date: Mon, 19 Jan 2026 17:45:48 -0300 Message-ID: <20260119205601.105821-13-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 c0c8d13030007..9e1c097ad0e4a 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 fa9e9ae16640f..b291c29160fc2 100644 --- a/tools/verification/rvgen/rvgen/dot2c.py +++ b/tools/verification/rvgen/rvgen/dot2c.py @@ -172,7 +172,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 291385adb2c20..de44840f63eda 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -109,8 +109,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 ea1fa0f5d818d..0491f8c9cb0b9 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -229,7 +229,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 Sun Feb 8 02:21:37 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 1B7512D780A for ; Mon, 19 Jan 2026 21:04:02 +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=1768856643; cv=none; b=NCT+PGISZnxF8F0qUxlKJ9I3IqrurRehN6n/zSQi6AQ4LywtSWUFqS8McBLy27pUOZPE3nGtnX24WHN/SaMVjaabFkgEbBF1SVOi4y1pDTR7sf4NH/F1x77SV1mHNSJhGmjXxJJzsFp/qRuE2ds12MnONsYv2HuUOYncCTksTog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856643; c=relaxed/simple; bh=Sev0AxPxk+Ra1wIo2x3p+hSwngzBbfV+r9yoXlchcsk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NTCiJu6ku0ZR+1hWUxjGdoBhP6N3VwwJZmKyHlKxHeTrlihPFX7/fzJxR0HUeXrU4+XLgbr/piJ+EGoWcxKnIVMcr2s07bp+VRtwLF0xzN1WsdvNp3RfctSztcGgYoR+vXGShOAbKGyBAyougWD/v9B23/B3gOzK9CW9PvuJjlM= 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=XGCS00/T; 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="XGCS00/T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856641; 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=yHSvuXe04YeXTc67naYFod2Dxdx676n/IX7g6FD7phU=; b=XGCS00/T6Q/CjhTdW/FdSv2Wg8o/3frFChQRphnB6Xjk8O3qAQ4WHREOQGq2L+HwSa4RzV 1NsiyA71amFke8FzjU6TocJKPc6l/+ihpB1RlBxYR5vg7TbZUgu6htZgksFtwZn5Z/pcD3 3CXhUgWf+F045df7j5pAWSL9axD4W68= 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-124-cRz6FxXLN7Gi7uwh-9D9OA-1; Mon, 19 Jan 2026 16:03:57 -0500 X-MC-Unique: cRz6FxXLN7Gi7uwh-9D9OA-1 X-Mimecast-MFC-AGG-ID: cRz6FxXLN7Gi7uwh-9D9OA_1768856636 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 EDBDA19560B0; Mon, 19 Jan 2026 21:03:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6017F1955F43; Mon, 19 Jan 2026 21:03:53 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 13/26] rv/rvgen: fix DOT file validation logic error Date: Mon, 19 Jan 2026 17:45:49 -0300 Message-ID: <20260119205601.105821-14-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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: Gabriele Monaco Reviewed-by: Nam Cao --- 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 9e1c097ad0e4a..7841a6e70bad2 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 Sun Feb 8 02:21:37 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 2B40F2DF6F6 for ; Mon, 19 Jan 2026 21:04:25 +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=1768856666; cv=none; b=FTPqQ/6R493quN9sHO4gA40XXJcCQWRA8ipHfU5makCK9q0I1zlkpF6dDeN5Udj7wo1jCRVq/mVem5zpk7Ri1PnXpilUfv7hgPqB02tnymkWyyoV+njaeQh4rWgl2dl/n2YN/gOhHMoom7V3WnnGV53MDR3uhMMDvOpXma4GjJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856666; c=relaxed/simple; bh=m9SgkT9h440yDgM1IFR3W05ovIC3RTHv6DSomoxtF6c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ADJu/jJKwiLLSsuWvPT/pSmaA1gLS1Lv+Axcaq7a8v0Hk5jr0N5sg9NJ01JZc73m5xMJPLwgsvQhQKrYQvLc/eIPYLdhRIIZoJqCCqDq+aYUWKgEYhg7IdHVzz5OW3XR/F7ZdHSYP5CTei5jMbTz5P5CKJaKkO97IA5vCJR2gaY= 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=RW+AJNr8; 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="RW+AJNr8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856664; 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=30iPcyx/O8od5igxVL7D4WfM9SXUj78edNZ/Hh8l0iU=; b=RW+AJNr8gJ7INq8wnh/emlHDOEh4YVOxqQjQeZ4SlnjqJRrYsvPTnMiavYVzxGfiJmul0p tA35r6L4KcDP2xbBuR7lyO3idJpMTg8VvmTyBDxirQQc8LTz3N03edOulM9x/xN1dhUaJ+ cstB1RIF7DVr+92UIQ64kDZmO/o6jfQ= 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-592-YVv8qnjTOS6Z50DaGdaPMw-1; Mon, 19 Jan 2026 16:04:21 -0500 X-MC-Unique: YVv8qnjTOS6Z50DaGdaPMw-1 X-Mimecast-MFC-AGG-ID: YVv8qnjTOS6Z50DaGdaPMw_1768856660 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 ECCD11954B06; Mon, 19 Jan 2026 21:04:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E34B19560AB; Mon, 19 Jan 2026 21:04:17 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 14/26] rv/rvgen: remove redundant initial_state removal Date: Mon, 19 Jan 2026 17:45:50 -0300 Message-ID: <20260119205601.105821-15-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Remove an unnecessary and incorrect list removal operation in the automata state variable processing. The code attempted to remove initial_state from the states list, but this element was never added to the list in the first place. States with the __init_ prefix are explicitly excluded from the states list during the parsing loop, with only the initial_state variable being set from them. Calling remove() on an element that does not exist in a list raises a ValueError. This code would have failed during execution when processing any DOT file containing an initial state marker. The subsequent insert operation at index 0 correctly adds the initial_state to the beginning of the states list, making the removal operation both incorrect and redundant. Signed-off-by: Wander Lairson Costa --- tools/verification/rvgen/rvgen/automata.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 7841a6e70bad2..b302af3e5133e 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -111,7 +111,6 @@ class Automata: cursor +=3D 1 =20 states =3D sorted(set(states)) - states.remove(initial_state) =20 # Insert the initial state at the beginning of the states states.insert(0, initial_state) --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 711A02ECE91 for ; Mon, 19 Jan 2026 21:04:47 +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=1768856688; cv=none; b=OXfDPIPlEssfikSIdijG/SOo+qhLRPRKyEc5jWFLvKjPBAtbI4z5P/X1CVu7yYB21tw80r/Kljc4FA3scetvvdzShwht4YgJttbM+UPm37BsIojIaipAxA5lfXhq5hrJ+hG7kV8GFEdI/woVN3m4z64ZKPyXv4SWQTFmgQNeJrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856688; c=relaxed/simple; bh=f2SqH/fw4uU2GRKBJhy3PgUfEnkJ0k0kZ7Wj00Pd78A=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=av720/hDzxeBcxSpVQhs/7bPXsjPauY4CTMpQAU6Fdhrpr9g9Fx8sXYCXEGN8lBBjePEVLfPmMt1aVqepaedLyu+MM0sRZts63wuAHXjbtB49n6lyhuWF+ZufCSS2wU8jlyzsc6IZSOHZ/6xKpW3klEcKC0f+eo/pwWEwPqtKKY= 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=f0vyYj9I; 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="f0vyYj9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856686; 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=oKSRzVqBoQOOo4lbHRVM5q4aKhOza8YqKKV/MGsaxoE=; b=f0vyYj9Iw81ColN45ABGJpDZjihpscYKB4nZYB3+w7MMQl/GMiFsSJCmY3dfmY/cewyfjj H4aYyT2ANRDYPfNr7nTvcorSvmMBWin8P7EWqkxPEh4w+s5JOT2yWdh4HylToqTDTDXOcQ txMv+LpJXVrH61yoVZ1yPxErVxBuvTs= 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-384-naREuLfuMpWfuNh6olJyqQ-1; Mon, 19 Jan 2026 16:04:45 -0500 X-MC-Unique: naREuLfuMpWfuNh6olJyqQ-1 X-Mimecast-MFC-AGG-ID: naREuLfuMpWfuNh6olJyqQ_1768856684 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 31CD21956095; Mon, 19 Jan 2026 21:04:44 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AC78D19560AB; Mon, 19 Jan 2026 21:04:41 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 15/26] rv/rvgen: use class constant for init marker Date: Mon, 19 Jan 2026 17:45:51 -0300 Message-ID: <20260119205601.105821-16-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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: Nam Cao --- 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 b302af3e5133e..8548265955570 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 Sun Feb 8 02:21:37 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 86FDB2E0B48 for ; Mon, 19 Jan 2026 21:05:13 +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=1768856714; cv=none; b=p44NNBNKgsuw9qO2zpqyBIGOhj9DXdseV1HYVugdMfHGKdqQYDB2oidjiVAdUIo5vAbvFCMzy7wbbcejjiLMH7NpjhTXkBmqgwWMO25XBhQmKn062v9NEuJUN128fAOLJhhPAB4Hp7egCHP1QtdhHceyTh/62+xMHku0Vj50W/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856714; c=relaxed/simple; bh=7DWaHBE+lufCXb7yGKuzsGpYm3Wlz4UGX3PpOWZN0lU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GfTYphNoRtZi4j+CeM/xlFJ3IP3ykRN02eYhScmWvvGjNidmegLvq1zfwOceVboiPG136AHOvkLOHdIGq+GCmMHsZ6opF95qH/gedWf0DtvG6ghP+F0GfBjqyEcmByFvcr6D8QuqoxuXZ2s+aW3fT8dEJ1+xADem8xzfW+hKYA8= 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=MJM7/Vh0; 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="MJM7/Vh0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856712; 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=7QayC2GyLW5anF6TqNfIzkKHxLfX0wSgqTgbD9DCUsY=; b=MJM7/Vh04svz4NMXEZF5uNtiBXKAglF/nUVPIj7rBayFEf97VYpAAkyUPG+39GWlGOHoT7 ixfqd+8HJ9kxyIcK88ljsrWV7DMttaI/Iz1vH87+FBPXiyH47J7Osur51CY2weqvo7r8TC UdAMzVJNIwOTbYqfncJO9cPmfEQyScU= 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-152-WD23MUZSNP-0xeaoBzVnEQ-1; Mon, 19 Jan 2026 16:05:09 -0500 X-MC-Unique: WD23MUZSNP-0xeaoBzVnEQ-1 X-Mimecast-MFC-AGG-ID: WD23MUZSNP-0xeaoBzVnEQ_1768856708 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 5287F1800350; Mon, 19 Jan 2026 21:05:08 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CA5A71955F43; Mon, 19 Jan 2026 21:05:05 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 16/26] rv/rvgen: fix unbound initial_state variable Date: Mon, 19 Jan 2026 17:45:52 -0300 Message-ID: <20260119205601.105821-17-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Initialize initial_state to None and validate its assignment after parsing DOT file state nodes. The previous implementation left initial_state uninitialized if the DOT file contained no state with the init_marker prefix, which would cause an UnboundLocalError when the code attempted to use the variable at the end of the function. This bug was identified by pyright static type checker, which correctly flagged that initial_state could be referenced before assignment. The fix adds proper initialization and validation, raising a AutomataError if no initial state marker is found in the automaton definition. This ensures that malformed DOT files missing an initial state are caught early with a clear error message rather than causing cryptic runtime exceptions. The change also includes minor code formatting improvements to comply with PEP 8 style guidelines, including consistent use of double quotes for string literals and proper line length formatting for improved readability. Signed-off-by: Wander Lairson Costa Reviewed-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/automata.py | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verificatio= n/rvgen/rvgen/automata.py index 8548265955570..083d0f5cfb773 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -10,6 +10,7 @@ =20 import ntpath =20 + class AutomataError(OSError): """Exception raised for errors in automata parsing and validation. =20 @@ -17,6 +18,7 @@ class AutomataError(OSError): or malformed automaton definitions. """ =20 + class Automata: """Automata class: Reads a dot file and parses it as an automata. =20 @@ -31,7 +33,9 @@ class Automata: self.__dot_path =3D file_path self.name =3D model_name or self.__get_model_name() self.__dot_lines =3D self.__open_dot() - self.states, self.initial_state, self.final_states =3D self.__get_= state_variables() + self.states, self.initial_state, self.final_states =3D ( + self.__get_state_variables() + ) self.events =3D self.__get_event_variables() self.function =3D self.__create_matrix() self.events_start, self.events_start_run =3D self.__store_init_eve= nts() @@ -86,6 +90,7 @@ class Automata: # wait for node declaration states =3D [] final_states =3D [] + initial_state =3D None =20 has_final_states =3D False cursor =3D self.__get_cursor_begin_states() @@ -96,9 +101,9 @@ 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.startswith(self.init_marker): - initial_state =3D state[len(self.init_marker):] + initial_state =3D state[len(self.init_marker) :] else: states.append(state) if "doublecircle" in self.__dot_lines[cursor]: @@ -111,6 +116,9 @@ class Automata: =20 cursor +=3D 1 =20 + if initial_state is None: + raise AutomataError("The automaton doesn't have a initial stat= e") + states =3D sorted(set(states)) =20 # Insert the initial state at the beginning of the states @@ -132,7 +140,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 +170,9 @@ 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 ran= ge(nr_state) + ] =20 # and we are back! Let's fill the matrix cursor =3D self.__get_cursor_begin_events() @@ -170,9 +180,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 --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 4E122239E75 for ; Mon, 19 Jan 2026 21:05:40 +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=1768856741; cv=none; b=NsGvr9QsCtj81ZJv2VV2lfDGBE7rH82Gr65BppJqo0elfKPhvBoLay8CFdjAl1YHQQoPcTsETzZBWrrwkZTidjlCsrxXfqgMzDrwuNFlsgj+h7YF4Hd0FzxstKgzHjUPP7MnQLoyJxMSGcnrnNMtLAMUt+MrQiBuUgX7Vt5y9T0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856741; c=relaxed/simple; bh=PAHEmTW6Z2vUfhafVBk2ibm6WyXb1Mlln0+M7rJ5Y5g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VtgCCyNuU7btoRJvkr+pB4B0eGR2ibxYiJxPHaddL830GvTI1awTDVkvJIsjJeluq1/uoCVdBpxAK1xo7tdH5jl3bwLgqboEO+kf3ec/mTmc9SnyvmTkWrozaEzeae3SLAqy/fkcdNGHztOJDu8qDRw1VaYqbS1cN25fZsb/4eY= 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=gZ+3/s8u; 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="gZ+3/s8u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856739; 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=AIXE+V/XZ3+xHzcF1ucLUFfUEL28iKIkkgtbegxGVzU=; b=gZ+3/s8um+kOZJsQ1EKS7Ji1hP2hj0Lcedj2bEFldbQi1q+re0od28xHn8TRBMtl0P7SHl 5sD1pN5RPu4Xr84ZF8X/7zPzktWsuucIAyzbQQuA8hkgFez6JR95+zbBHpF4+qXpYmCHAx cp3/mlHOHkJeWut/qUUBlCQnSMyD+LE= 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-618-5DQVV7zBO_eftzcHD3OmEg-1; Mon, 19 Jan 2026 16:05:33 -0500 X-MC-Unique: 5DQVV7zBO_eftzcHD3OmEg-1 X-Mimecast-MFC-AGG-ID: 5DQVV7zBO_eftzcHD3OmEg_1768856732 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 8A0F3195605A; Mon, 19 Jan 2026 21:05:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0FA5919560AB; Mon, 19 Jan 2026 21:05:29 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 17/26] rv/rvgen: fix possibly unbound variable in ltl2k Date: Mon, 19 Jan 2026 17:45:53 -0300 Message-ID: <20260119205601.105821-18-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Initialize loop variable `i` before the for loop in abbreviate_atoms function to fix pyright static type checker error. The previous code left `i` potentially unbound in edge cases where the range could be empty, though this would not occur in practice since the loop always executes at least once with the given range parameters. The initialization to zero ensures that `i` has a defined value before entering the loop scope, satisfying static analysis requirements while preserving the existing logic. The for loop immediately assigns i to the first value from the range, so the initialization value is never actually used in normal execution paths. This change resolves the pyright reportPossiblyUnbound error without altering the function's behavior or performance characteristics. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/ltl2k.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index fa9ea6d597095..94dc64af1716d 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -45,6 +45,7 @@ def abbreviate_atoms(atoms: list[str]) -> list[str]: =20 abbrs =3D [] for atom in atoms: + i =3D 0 for i in range(len(atom), -1, -1): if sum(a.startswith(atom[:i]) for a in atoms) > 1: break --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 6D7572F744A for ; Mon, 19 Jan 2026 21:06:00 +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=1768856762; cv=none; b=MgKRyr82XAZ+1twtTln61pAH7XlaP5Ek8d/M5m+NWrKuQu3x7chzg5MVCro7CecUK7TxutN5Id8kctoAGr/mg1Cti/fVIVG0Qsz1V3gExDC0nD6nYg/dpOUU6LrF7y/Y7iRVC6jChkBU4CoQI3Z/Q9gyC6dPlFhaFpGLT+OVHsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856762; c=relaxed/simple; bh=ulkyx3dFM1g81OXVdkTp9iCr+3y036Jq7Gt3gOY6cMA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MxLbsW1OQqN8PLaxOTjB10HDEiZwkYX1xVGsgn3Wg6McZYP5H1b1K14/dPXyNMxnTxDsNaeh55C6MS+jkFtdx4HHWJwAAWfLHnrMOL0gg7spbC4k9BY0hLO/yOuUVQk0kAqBFYkJCy9bQ1wPcs9o4IFNEHPcxXyD4qp2CdwokPo= 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=QdktsXGx; 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="QdktsXGx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856759; 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=w36A691xcoG0dFs107/UAjpDXJJuV8dxC4+rej1wdBE=; b=QdktsXGxAJ9YypC+NDySIvuo/o8z/QMxRs2Bj2+NGYEw9OjBZ0GGIPHjD5AYiC9qeJMkPa RYPQokp3CViOOwqOumHdJNfrP4ZA17LZie6dCtB2vsYcRz7bUy4ioJNsMhimlW2GIQ7ijD OHpJ/wVLp/NswBqlcFG0Pf/jbCqOick= 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-688-IoJZV2SQPe6cMEodh-boww-1; Mon, 19 Jan 2026 16:05:57 -0500 X-MC-Unique: IoJZV2SQPe6cMEodh-boww-1 X-Mimecast-MFC-AGG-ID: IoJZV2SQPe6cMEodh-boww_1768856757 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 E4DC618005BA; Mon, 19 Jan 2026 21:05:56 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6AD5119560AB; Mon, 19 Jan 2026 21:05:54 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 18/26] rv/rvgen: add fill_tracepoint_args_skel stub to ltl2k Date: Mon, 19 Jan 2026 17:45:54 -0300 Message-ID: <20260119205601.105821-19-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" The ltl2k class inherits from Monitor which requires subclasses to implement fill_tracepoint_args_skel(). However, the ltl2k template uses hardcoded tracepoint arguments rather than the placeholders that this method would fill. The base class fill_trace_h() method calls fill_tracepoint_args_skel() unconditionally, which was exposed when the @not_implemented decorator was introduced. Add a stub implementation that returns an empty string. Since the ltl2k trace.h template does not contain the placeholder strings that would be replaced, the empty return value has no effect on the generated output while satisfying the base class interface contract. Signed-off-by: Wander Lairson Costa --- tools/verification/rvgen/rvgen/ltl2k.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index 94dc64af1716d..f1eafc16c754b 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -257,6 +257,9 @@ class ltl2k(generator.Monitor): =20 return '\n'.join(buf) =20 + def fill_tracepoint_args_skel(self, tp_type) -> str: + return "" + def fill_monitor_class_type(self): return "LTL_MON_EVENTS_ID" =20 --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 7B431239E75 for ; Mon, 19 Jan 2026 21:06:27 +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=1768856788; cv=none; b=FscFnauKXLVRmVEJYvT2CpV2WSifkNNa9qg2KUbNWtj+OaQw6Tkki2nsu7mUfloNWS9SeqO1P78ubJVAqCOxR2zbzU0m3op9rvEZ5cnMQBBaqdmXtgtsPJe107f6msHl5MLuw6B8AnTpdx5WRdFtzVqKKFK3pRpQLmzEgODyc/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856788; c=relaxed/simple; bh=Yy25pbOzQY6/67FaeeOQExnC7iSweIy85nMShC6rW2Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IkO7raN/UDAuY0I6rrCiVGMBgKABmBbucid+L7gPWn33N0EmvvqZZWe/SiBPLIaDAaZQ31up0kJWV8KsEZKJpgSR77UlXJorsHpk/KCfyGqHeZB5ghoaikMrj5i5MGX7pvbVjODahxkEUzsIpKW7R9q0V0aPPG656kdwqrzzPNA= 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=h425A1Wf; 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="h425A1Wf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856786; 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=kjiIcWBI340zaieB4Zxm5IDzcw38iqhycJCiEUWs664=; b=h425A1Wf4Lwz5t/2sRjPqIHwxjxvUzou02YoTkBedp0ji+ldqExj6abQ5loWk1rtVb+lRo BS23jjlBC8zcilwPNNBVnl+XI3B3nldwFEvfx0pLmmrmL1T7B44hUn+DAinNbCaqXDPxbl A4+eCMEVzMeV4id9UI3dYAsozuuW9MQ= 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-590--A3fUC0QMzKeBb2T6Bm6cQ-1; Mon, 19 Jan 2026 16:06:22 -0500 X-MC-Unique: -A3fUC0QMzKeBb2T6Bm6cQ-1 X-Mimecast-MFC-AGG-ID: -A3fUC0QMzKeBb2T6Bm6cQ_1768856781 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 4D5F81956094; Mon, 19 Jan 2026 21:06:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6D8C19560AB; Mon, 19 Jan 2026 21:06:18 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 19/26] rv/rvgen: add abstract method stubs to Container class Date: Mon, 19 Jan 2026 17:45:55 -0300 Message-ID: <20260119205601.105821-20-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" The Container class extends RVGenerator but was missing implementations for several abstract methods decorated with @not_implemented in the base class. This could lead to NotImplementedError exceptions if code paths attempt to call these methods on Container instances. Add empty-string returning stub implementations for fill_tracepoint_handler= s_skel, fill_tracepoint_attach_probe, fill_tracepoint_detach_helper, and fill_monitor_class_type. These empty returns are semantically correct since Container is a grouping mechanism for organizing monitors, not an actual monitor that generates tracepoint-specific C code. Signed-off-by: Wander Lairson Costa --- tools/verification/rvgen/rvgen/container.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/verification/rvgen/rvgen/container.py b/tools/verificati= on/rvgen/rvgen/container.py index 51f188530b4dd..65df21dfd17b2 100644 --- a/tools/verification/rvgen/rvgen/container.py +++ b/tools/verification/rvgen/rvgen/container.py @@ -30,3 +30,15 @@ class Container(generator.RVGenerator): self._kconfig_marker(), container_marker) return result return result + container_marker + + def fill_tracepoint_handlers_skel(self) -> str: + return "" + + def fill_tracepoint_attach_probe(self) -> str: + return "" + + def fill_tracepoint_detach_helper(self) -> str: + return "" + + def fill_monitor_class_type(self) -> str: + return "" --=20 2.52.0 From nobody Sun Feb 8 02:21:37 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 EB098239E75 for ; Mon, 19 Jan 2026 21:06:50 +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=1768856812; cv=none; b=ntt4EdSImxmaxmZBCQr3v8qGKLdfa5FtndOQ/5E84kKsHjYTYPMRtT7zqbOqZN49b9pgGPSv2Mbphl2TvLRHf/sGmHP1nJAHZfBsnbcqnwZSvu3gncZ1EPSZZek92PqSoiFZncy5mEqfh46S1l9NcEIkfqYuP7SrlZfU3MbgyGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856812; c=relaxed/simple; bh=Cv7xdVb8TPBh5SD/przOy40ZShHXp7REu15vrs83Fpk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K0SCdE6HN8pawQ4pZJr7NS+iMl8uCerTJvKvJ++2BbE4kOYAPvHMLM5OcwQ6o5B7LDXZ8IC41Yuk3ZVAa3nBKyuFuiTeNlw7Xl+9dpyYdxNiz8+MJdw2Go5mBsPBVnnizNoZGfy0CA1g9Jk9JMAxC+e9uJi04ezHoLUZ9H8PbMU= 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=gEn+kGp3; 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="gEn+kGp3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856810; 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=NAhJpBpuwY85AzW6pQHTpyADsq9b83OtuK/qOzl5+7M=; b=gEn+kGp3ZY0QEE4zi/hbWVNnaILHQayS8sEeaCdWFaMlBEumzINY5z6TvLuajP+CMi1AIh gedyuI7XBKmscldswr35EQcL3HNXkTkEIvRO/iwKX1Gb9a2RKEHyi79eE60gFnbSA26jdq bxQjOq0YrMSSc/y1Vp4zAASZy1sHsyI= 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-515-BrduNxfKPBGLa-p8j_kXqA-1; Mon, 19 Jan 2026 16:06:46 -0500 X-MC-Unique: BrduNxfKPBGLa-p8j_kXqA-1 X-Mimecast-MFC-AGG-ID: BrduNxfKPBGLa-p8j_kXqA_1768856805 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 CC8B01956048; Mon, 19 Jan 2026 21:06:45 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4DC6319560AB; Mon, 19 Jan 2026 21:06:43 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 20/26] rv/rvgen: refactor automata.py to use iterator-based parsing Date: Mon, 19 Jan 2026 17:45:56 -0300 Message-ID: <20260119205601.105821-21-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 083d0f5cfb773..a6889d0c26c3f 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 =20 class AutomataError(OSError): @@ -53,37 +54,54 @@ class Automata: return model_name =20 def __open_dot(self): - 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): - 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): - 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): @@ -96,9 +114,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= (",", "_") @@ -106,16 +127,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 - if initial_state is None: raise AutomataError("The automaton doesn't have a initial stat= e") =20 @@ -130,26 +149,27 @@ class Automata: return states, initial_state, final_states =20 def __get_event_variables(self): + 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 @@ -171,32 +191,37 @@ class Automata: =20 # declare the matrix.... matrix =3D [ - [self.invalid_state_str for x in range(nr_event)] for y in ran= ge(nr_state) + [self.invalid_state_str for _ in range(nr_event)] for _ in ran= ge(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): 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 Sun Feb 8 02:21:37 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 9B5592F7475 for ; Mon, 19 Jan 2026 21:07:15 +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=1768856836; cv=none; b=e/bSJ7+D7Pb8dCLmMiQjPGFBbp6lXz1giRn1sjOso+sB5i0qMCPGm8yJtnzrahSi/BHXoVsTnaVB8xhtcihl9AijzGNDfmH6cU39jBl/3DNUPZxaLn2Al9BcHmcE4cJmFxhE41aQzC4gD11SOPqcu8o1e3tUpbYKu9Rlp8scN34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856836; c=relaxed/simple; bh=cRu5YyFyW5ncz8d6STwz6wUFck73wJUX3RXcijE+riU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CMRq/+NCq4L7END4kXH/tpz7NMG2aTaFXDNMEgpqLWknEUMHe7lI5lBNsmYxXuO52Yfu7/8z6kL3aPfID7YF8jcvqQ66+IT9AK6NZOSgQblmgMdiGrGcw79uJU5YfeBbdD3vqW6Arvq9nOiNipQAdbF8HHr0YOUx+0j+zUEmigA= 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=QTmDSnOD; 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="QTmDSnOD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856834; 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=h1WMJMRweu7596gWptGsF6jL9Z0Hnc5bO/Q32rTlSFI=; b=QTmDSnOD7BK9S5rMcklqrIg8kzJ3F0CZB8uo4eowiatrGDVOlCRYXYSzAYzxt9tXKdA04K uGsMQ0QlUuYYQ9KcWkT0u0bJmtaVWdX/NeAj3oZ7xs4K2loAzi1GumDU50ggHIsfVz4X4a WeyhV6BvUShtu5xQfykmg11QAyz4xh0= 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-562-c80JDzhRNZ2rQ1ojstpLpw-1; Mon, 19 Jan 2026 16:07:11 -0500 X-MC-Unique: c80JDzhRNZ2rQ1ojstpLpw-1 X-Mimecast-MFC-AGG-ID: c80JDzhRNZ2rQ1ojstpLpw_1768856830 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 79A4D1800447; Mon, 19 Jan 2026 21:07:10 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EA6B919560AB; Mon, 19 Jan 2026 21:07:07 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 21/26] rv/rvgen: remove unused sys import from dot2c Date: Mon, 19 Jan 2026 17:45:57 -0300 Message-ID: <20260119205601.105821-22-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 Sun Feb 8 02:21:37 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 A9491231C91 for ; Mon, 19 Jan 2026 21:07: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=1768856860; cv=none; b=TBRTFmBrEd5YbnyGOB3a7YwHsdQ8JN+HuS76/GZ3XnXQyeD//P9XMYfhoDBZFsqBf+ULvHfMv9rkbWYo59+ycKZat8SjQoL6P67ScT27jAj5TDnd2VEf1tLvBL+Y3/yc7WPDL5elO5UEF5/djYAAgFVGBJ3LsiZMQeElvAu0PGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856860; c=relaxed/simple; bh=GZaOPASEgrZkIRICJQl/+LmCBgYcyEIyj6h8O0kP+Bw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=reZdmIKDkTiHhD5HxZEpelzHVsIm4sCwLsFZR2WiExHZfJ+K3ZPC4F7HHxk4ZnagidWpv0PJe8uRNK3pk23qT4qKScaV29Gu/qAi7LY023w7aV4MKZDhKcNuFSMFHfFjZlgtVHzC/d2Z8LWaOP08lf2EH3Xxf90RXiGqRDdVN/0= 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=PMC4gO3k; 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="PMC4gO3k" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856857; 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=FGb/DuLN1+vE5tOzXIe0x32jZRV7k3bqvXrHwN8Xo5c=; b=PMC4gO3k3S+/f2H5w/TTfSqcH1xd9jeD+yezMhmIlYFxabiJrRWLZ1dGyjJozBkzWQo+At Bg7HcZrnGDLW/vnytJ7Xbcj+kB+fA3Qq40RVMjlJ6qAxYt2Ue5m/fBaLOFd8n63F6/VobX /kFQ7T9sSVSXTmGh6jkgSb4wez4UKjM= 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-22-FDoqEXTXON2LI6P65QmqFw-1; Mon, 19 Jan 2026 16:07:36 -0500 X-MC-Unique: FDoqEXTXON2LI6P65QmqFw-1 X-Mimecast-MFC-AGG-ID: FDoqEXTXON2LI6P65QmqFw_1768856855 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 0416A18005B2; Mon, 19 Jan 2026 21:07:35 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7489119560AB; Mon, 19 Jan 2026 21:07:32 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 22/26] rv/rvgen: remove unused __get_main_name method Date: Mon, 19 Jan 2026 17:45:58 -0300 Message-ID: <20260119205601.105821-23-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 0491f8c9cb0b9..d99a980850d64 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -206,12 +206,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 Sun Feb 8 02:21:37 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 CF66A2E0B48 for ; Mon, 19 Jan 2026 21:08:04 +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=1768856887; cv=none; b=AQp2AH3/rBAmoqPjihzDyciVJZSbAnkPN+PvBgZsEDUAuumlrsso2FsrGhi0vPuxU7+OgRj+Dmj6um7JUo4VkHXgWXWywJEzMPMPtixQuDoy63XBqQAyaKH4lPmECLn21UMWSElwwkfx6wGznmm7a1T6wW/8tPpBWppK4spSRW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856887; c=relaxed/simple; bh=CfZHGU9rAZCkxcJo6GF+wsIc1/L4cXtenRegcxb04NU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gcYch8tcqGJGA15+A2cmu71WPf++FE3lzx9/J9P9jnQcL8ikPuOI8e5iPs5ItqC69KldhcUebxfqM+s+ctwdYuojskDgnvbYvX27bFpIV6KN1bCqybMh8GEc2NCE1AXebcBc8Plsx0sK2fPGlBVp4TLuUCYzbsBV2zkWHWguZpc= 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=VRK00jqf; 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="VRK00jqf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856883; 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=Lv86rSujb1th/HGt0eBVWDgWUHvu2gpQrKGVJxmc+Bc=; b=VRK00jqfPbtrIZDPctU5GFzttcnlLVshn/25t7iQI0/Pfp38pHy/3vdcUUrJUyzG49uXu7 EEwX5vxbM06hHv8FGdqewhk2wPFTSBIGQ+5Ep6LyALSku++hoPgH5b5t+YkFdtlpifwRPH F0ogBjxNyyqgow0cUaHzNRBLs9jnwoM= 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-677-h6YaOZo7OQObv8GBVkXWNA-1; Mon, 19 Jan 2026 16:08:00 -0500 X-MC-Unique: h6YaOZo7OQObv8GBVkXWNA-1 X-Mimecast-MFC-AGG-ID: h6YaOZo7OQObv8GBVkXWNA_1768856879 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 802961954B0C; Mon, 19 Jan 2026 21:07:59 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04B5819560AB; Mon, 19 Jan 2026 21:07:56 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 23/26] rv/rvgen: add type annotations to fix pyright errors Date: Mon, 19 Jan 2026 17:45:59 -0300 Message-ID: <20260119205601.105821-24-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Add return type annotations to RVGenerator base class methods and LTL operator classes to resolve pyright reportIncompatibleMethodOverride errors. In generator.py, add string return type annotations to all template filling methods and annotate the template_dir class attribute to enable proper type checking during initialization. In ltl2ba.py, introduce a LTLNode type alias as a Union of all AST node types (BinaryOp, UnaryOp, Variable, Literal) to properly type operator transformations. The operator base classes BinaryOp and UnaryOp receive return type annotations using this type alias for their normalize and negate methods, since these transformations can return different node types depending on the expression. The Variable and Literal classes gain return type annotations for their manipulation methods, and all temporal checking methods are annotated to return bool. The LTLNode type alias is necessary because operator transformations are polymorphic: NotOp.negate() can return BinaryOp, UnaryOp, Variable, or Literal depending on what expression is being negated. In ltl2k.py, fix the _fill_states return type from str to list[str] to match the actual implementation. Signed-off-by: Wander Lairson Costa Reviewed-by: Nam Cao --- tools/verification/rvgen/rvgen/generator.py | 35 +++++++++++---------- tools/verification/rvgen/rvgen/ltl2ba.py | 33 ++++++++++--------- tools/verification/rvgen/rvgen/ltl2k.py | 2 +- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verificati= on/rvgen/rvgen/generator.py index d99a980850d64..c58a81a775681 100644 --- a/tools/verification/rvgen/rvgen/generator.py +++ b/tools/verification/rvgen/rvgen/generator.py @@ -12,6 +12,7 @@ from .utils import not_implemented =20 class RVGenerator: rv_dir =3D "kernel/trace/rv" + template_dir: str =20 def __init__(self, extra_params=3D{}): self.name =3D extra_params.get("model_name") @@ -66,24 +67,24 @@ class RVGenerator: path =3D os.path.join(self.abs_template_dir, "..", file) return self._read_file(path) =20 - def fill_parent(self): + def fill_parent(self) -> str: return f"&rv_{self.parent}" if self.parent else "NULL" =20 - def fill_include_parent(self): + def fill_include_parent(self) -> str: if self.parent: return f"#include \n" return "" =20 @not_implemented - def fill_tracepoint_handlers_skel(self): ... + def fill_tracepoint_handlers_skel(self) -> str: ... =20 @not_implemented - def fill_tracepoint_attach_probe(self): ... + def fill_tracepoint_attach_probe(self) -> str: ... =20 @not_implemented - def fill_tracepoint_detach_helper(self): ... + def fill_tracepoint_detach_helper(self) -> str: ... =20 - def fill_main_c(self): + def fill_main_c(self) -> str: main_c =3D self.main_c tracepoint_handlers =3D self.fill_tracepoint_handlers_skel() tracepoint_attach =3D self.fill_tracepoint_attach_probe() @@ -102,18 +103,18 @@ class RVGenerator: return main_c =20 @not_implemented - def fill_model_h(self): ... + def fill_model_h(self) -> str: ... =20 @not_implemented - def fill_monitor_class_type(self): ... + def fill_monitor_class_type(self) -> str: ... =20 @not_implemented - def fill_monitor_class(self): ... + def fill_monitor_class(self) -> str: ... =20 @not_implemented - def fill_tracepoint_args_skel(self, tp_type): ... + def fill_tracepoint_args_skel(self, tp_type) -> str: ... =20 - def fill_monitor_deps(self): + def fill_monitor_deps(self) -> str: buff =3D [] buff.append(" # XXX: add dependencies if there") if self.parent: @@ -121,7 +122,7 @@ class RVGenerator: buff.append(" default y") return '\n'.join(buff) =20 - def fill_kconfig(self): + def fill_kconfig(self) -> str: kconfig =3D self.kconfig monitor_class_type =3D self.fill_monitor_class_type() monitor_deps =3D self.fill_monitor_deps() @@ -139,7 +140,7 @@ class RVGenerator: content =3D content.replace(marker, line + "\n" + marker) self.__write_file(file_to_patch, content) =20 - def fill_tracepoint_tooltip(self): + def fill_tracepoint_tooltip(self) -> str: monitor_class_type =3D self.fill_monitor_class_type() if self.auto_patch: self._patch_file("rv_trace.h", @@ -155,7 +156,7 @@ Add this line where other tracepoints are included and = {monitor_class_type} is d def _kconfig_marker(self, container=3DNone) -> str: return f"# Add new {container + ' ' if container else ''}monitors = here" =20 - def fill_kconfig_tooltip(self): + def fill_kconfig_tooltip(self) -> str: if self.auto_patch: # monitors with a container should stay together in the Kconfig self._patch_file("Kconfig", @@ -168,7 +169,7 @@ Add this line where other monitors are included: source \"kernel/trace/rv/monitors/{self.name}/Kconfig\" """ =20 - def fill_makefile_tooltip(self): + def fill_makefile_tooltip(self) -> str: name =3D self.name name_up =3D name.upper() if self.auto_patch: @@ -182,7 +183,7 @@ Add this line where other monitors are included: obj-$(CONFIG_RV_MON_{name_up}) +=3D monitors/{name}/{name}.o """ =20 - def fill_monitor_tooltip(self): + def fill_monitor_tooltip(self) -> str: if self.auto_patch: 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)" @@ -229,7 +230,7 @@ class Monitor(RVGenerator): super().__init__(extra_params) self.trace_h =3D self._read_template_file("trace.h") =20 - def fill_trace_h(self): + def fill_trace_h(self) -> str: trace_h =3D self.trace_h monitor_class =3D self.fill_monitor_class() monitor_class_type =3D self.fill_monitor_class_type() diff --git a/tools/verification/rvgen/rvgen/ltl2ba.py b/tools/verification/= rvgen/rvgen/ltl2ba.py index 9a3fb7c5f4f65..49f6b9200ff0a 100644 --- a/tools/verification/rvgen/rvgen/ltl2ba.py +++ b/tools/verification/rvgen/rvgen/ltl2ba.py @@ -7,10 +7,15 @@ # https://doi.org/10.1007/978-0-387-34892-6_1 # With extra optimizations =20 +from __future__ import annotations +from typing import Union from ply.lex import lex from ply.yacc import yacc from .utils import not_implemented =20 +# Type alias for all LTL node types in the AST +LTLNode =3D Union['BinaryOp', 'UnaryOp', 'Variable', 'Literal'] + # Grammar: # ltl ::=3D opd | ( ltl ) | ltl binop ltl | unop ltl # @@ -152,15 +157,15 @@ class BinaryOp: yield from self.right =20 @not_implemented - def normalize(self): ... + def normalize(self) -> BinaryOp: ... =20 @not_implemented - def negate(self): ... + def negate(self) -> BinaryOp: ... =20 @not_implemented - def _is_temporal(self): ... + def _is_temporal(self) -> bool: ... =20 - def is_temporal(self): + def is_temporal(self) -> bool: if self.left.op.is_temporal(): return True if self.right.op.is_temporal(): @@ -291,20 +296,20 @@ class UnaryOp: return hash(self.child) =20 @not_implemented - def normalize(self): + def normalize(self) -> LTLNode: ... =20 @not_implemented - def _is_temporal(self): + def _is_temporal(self) -> bool: ... =20 - def is_temporal(self): + def is_temporal(self) -> bool: if self.child.op.is_temporal(): return True return self._is_temporal() =20 @not_implemented - def negate(self): + def negate(self) -> LTLNode: ... =20 class EventuallyOp(UnaryOp): @@ -386,14 +391,14 @@ class Variable: def __iter__(self): yield from () =20 - def negate(self): + def negate(self) -> NotOp: new =3D ASTNode(self) return NotOp(new) =20 - def normalize(self): + def normalize(self) -> Variable: return self =20 - def is_temporal(self): + def is_temporal(self) -> bool: return False =20 @staticmethod @@ -419,14 +424,14 @@ class Literal: return "true" return "false" =20 - def negate(self): + def negate(self) -> Literal: self.value =3D not self.value return self =20 - def normalize(self): + def normalize(self) -> Literal: return self =20 - def is_temporal(self): + def is_temporal(self) -> bool: return False =20 @staticmethod diff --git a/tools/verification/rvgen/rvgen/ltl2k.py b/tools/verification/r= vgen/rvgen/ltl2k.py index f1eafc16c754b..44231aadb257c 100644 --- a/tools/verification/rvgen/rvgen/ltl2k.py +++ b/tools/verification/rvgen/rvgen/ltl2k.py @@ -68,7 +68,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 Sun Feb 8 02:21:37 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 0A234239E75 for ; Mon, 19 Jan 2026 21:08:29 +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=1768856911; cv=none; b=CFvlbnSiGndVGl/oKcywLsZWSJdSd+y+PpCwR6FVGSITEURN6G0a2xiRzGHoBeamrlreFcUtBct4FJ+e6tfUDzwg9ueDJ6EcG+SmHvDYbyn81Q7xsIJcF7XOPZPz9Eg79zWYM76xWXDKoKyLv1krxMT1kZ+ZJRp6/IJmGFOnQFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856911; c=relaxed/simple; bh=3N+pdb9b2gz7OYWhhC2LnYEQG8AAcdtLz2HIbt4U5AQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h+W9rbxbjqgcOBCFxiyW6Y8Nkj1+hs56V+lqzBqM0OnAB64x9F6TlLlvZeHydmGfV2pzBE9d1eQhYe6PgDQeKGggbAla4dwr9KGxV79Ssb5NgHqO2SqPAz0zcRnzQFuFUBJGYbdV7gi5aqQOoDiJKbVjytVpZPmoMiVu7OyGmQc= 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=YOdSAM23; 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="YOdSAM23" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856909; 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=VfYhHmPFMzfU5sr2QO5tgwXVLa7hzCKz+9w5grrucRI=; b=YOdSAM23pNKnz2fKVwzkqhmNXW9rIDRqgASpeo+WUSiLJvaRkruf7ltHoPMg5khPuThGXs R3UXYpj+1g4gmwNQ7k+goIwnaAXJFQHlCd3hFbb5nANjcDU/25lfuGdnC1oR6Y1Hg+tFkB a70U0Vnbazqh0yHGNg/kP/OPXjSqkSs= 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-397-QLT9wr7wOMy4J5YzTykjHg-1; Mon, 19 Jan 2026 16:08:26 -0500 X-MC-Unique: QLT9wr7wOMy4J5YzTykjHg-1 X-Mimecast-MFC-AGG-ID: QLT9wr7wOMy4J5YzTykjHg_1768856904 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 F003219560B2; Mon, 19 Jan 2026 21:08:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7391C1955F43; Mon, 19 Jan 2026 21:08:21 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 24/26] rv/rvgen: make monitor arguments required in rvgen Date: Mon, 19 Jan 2026 17:46:00 -0300 Message-ID: <20260119205601.105821-25-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 eeeccf81d4b90..f3e79b14c5d5d 100644 --- a/tools/verification/rvgen/__main__.py +++ b/tools/verification/rvgen/__main__.py @@ -28,10 +28,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 Sun Feb 8 02:21:37 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 CFBB92E0B48 for ; Mon, 19 Jan 2026 21:08:53 +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=1768856935; cv=none; b=kYpwgs+yXi64OxtsYZTNto/YXAGTWsJR4aPlMf8vuaUi+gXCxYnQcQ8uO37adRJGCGKwDOst5Tfq+8Q0JVqcqe3uUR7oE2woZCi9RYBAKsuyCSKJ+UNaJLTFGNTQtUzGHV7IcQI2hq+dxfg9OD8kSR5zzROKsnWMwyy9ThhGFFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856935; c=relaxed/simple; bh=c5xB9bQ2gRYuiiCkqKN8cGNiCtTlsD6giWS1xZpe9Uc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ULJsqGWNWpGrUaEGRdkisE78AjSqk5GSeGZI4Yn2IzJshpIWzPfs7awbESqrcPDbQq7EgGyN79knJ4u/wl10T3lzxmpoWuaWGdwUWocaGCHc1Yps2hBfi1FRgUvzAWf9RDxRExKnSMbSGE5Mag1WZjNjGpAP2A5rcrvlIcavxE0= 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=JmQnhJkD; 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="JmQnhJkD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856933; 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=ShCVTmEOtwDXLNQOXcJsi+RugUD0oHWkctfo1fKXMms=; b=JmQnhJkDlSKj6tl777gPO2CpctO9YTLXQrH7wymILor8fvze8G1GCCgUz+8EHxuPyLDudg UsQqHzDTjzXwYCGjEr9vSepBSR2eLS4HP33cjvdgkK2K+JB5aij3bSc4cypeSEux8hUthY IQfNIEGeqiCp4yCWML0j0LRdlxDicR4= 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-395-LZxGZVdoOzG1SvW60N5WoQ-1; Mon, 19 Jan 2026 16:08:49 -0500 X-MC-Unique: LZxGZVdoOzG1SvW60N5WoQ-1 X-Mimecast-MFC-AGG-ID: LZxGZVdoOzG1SvW60N5WoQ_1768856928 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 8AF6919560A3; Mon, 19 Jan 2026 21:08:48 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EA43B19560AB; Mon, 19 Jan 2026 21:08:45 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 25/26] rv/rvgen: fix isinstance check in Variable.expand() Date: Mon, 19 Jan 2026 17:46:01 -0300 Message-ID: <20260119205601.105821-26-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 49f6b9200ff0a..79b45a1d61130 100644 --- a/tools/verification/rvgen/rvgen/ltl2ba.py +++ b/tools/verification/rvgen/rvgen/ltl2ba.py @@ -404,7 +404,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 Sun Feb 8 02:21:37 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 18F112F745B for ; Mon, 19 Jan 2026 21:09:17 +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=1768856959; cv=none; b=Cx9uGJqO9pE4xaETsRNaHo1yuVVGos2mF//JvumiIG3aice/RMH0RgP7eVAKSvDgWe6lgwvWBbA6WH0sZmkGF2LvC+aWKbLzEPTFfIEhWEJeDO4lmKOSikVj1jjrVRhNCZigCoUywuJ02A+w8Yqe8MMUsnjNHTgB8sbcckqNWv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768856959; c=relaxed/simple; bh=UE5EVzP4Jwg5WCln9kZqxFNFL4Bs4RBJZ9N5G//80pw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxgzDiv/qGtqUFyl+ZBOzFBv9pSQdEpdCJEdLcQGmNoB9y0ieJbHSNu9TISQp/l0uq7rYtD7E9XCTAlA8eEFshJsl+3k+MTcm9T44g8y16q1+tBhugsPf6+864LNObKt07RjAlPr+lpYNgP4LU8IFEo/prDAMtfA8Lohtl0Ht/o= 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=KhgzItfr; 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="KhgzItfr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768856957; 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=0+P/u9BoRMOUVSt4UIw4hbVr4uE91hZVlQvF2Pvoxxk=; b=KhgzItfrBrk0hCBJJFbM/2y9XPwr0PqxiZXCk84F4Er57KOQEq5AcVxQuO5swvjLs2YQml kmnGI2gA3YD5Dy71AV3z3T4eJTZrJRWUg//VBV5+Eop6BtbgKZCyV9aSwIDFjGPlU8rBAW 8DT4YkZ7I+dWwLPTHsMVEzoLR5JRkR0= 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-377-a7aJK8nYO4KrqxRaE2wvAA-1; Mon, 19 Jan 2026 16:09:13 -0500 X-MC-Unique: a7aJK8nYO4KrqxRaE2wvAA-1 X-Mimecast-MFC-AGG-ID: a7aJK8nYO4KrqxRaE2wvAA_1768856952 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 C4F6A1956080; Mon, 19 Jan 2026 21:09:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.137]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46DE819560AB; Mon, 19 Jan 2026 21:09:10 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Gabriele Monaco , Nam Cao , Wander Lairson Costa , linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:RUNTIME VERIFICATION (RV)) Subject: [PATCH 26/26] rv/rvgen: extract node marker string to class constant Date: Mon, 19 Jan 2026 17:46:02 -0300 Message-ID: <20260119205601.105821-27-wander@redhat.com> In-Reply-To: <20260119205601.105821-1-wander@redhat.com> References: <20260119205601.105821-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.0 on 10.30.177.17 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 a6889d0c26c3f..5f23db1855cd3 100644 --- a/tools/verification/rvgen/rvgen/automata.py +++ b/tools/verification/rvgen/rvgen/automata.py @@ -29,6 +29,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 @@ -76,7 +77,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") @@ -91,9 +92,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") @@ -116,7 +117,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