summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@kernel.org>2026-01-27 11:35:43 -0500
committerTamir Duberstein <tamird@kernel.org>2026-03-09 13:20:09 -0400
commit9b4744d8eda2824041064a5639ccbb079850914d (patch)
tree650ea0fa0c988d71343481050f341123a4803cc6 /scripts
parent36c619f6bd793493294becb10a02fea370b67a91 (diff)
scripts: generate_rust_analyzer.py: avoid FD leak
Use `pathlib.Path.read_text()` to avoid leaking file descriptors. Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`") Cc: stable@vger.kernel.org Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Fiona Behrens <me@kloenk.dev> Reviewed-by: Trevor Gross <tmgross@umich.edu> Link: https://patch.msgid.link/20260127-rust-analyzer-fd-leak-v2-1-1bb55b9b6822@kernel.org Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_rust_analyzer.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 38e834bd209e..024e71a742e0 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -313,9 +313,10 @@ def generate_crates(
def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
try:
- return f"{target}.o" in open(build_file).read()
+ contents = build_file.read_text()
except FileNotFoundError:
return False
+ return f"{target}.o" in contents
# Then, the rest outside of `rust/`.
#