Skip to content

Commit 9b4744d

Browse files
committed
scripts: generate_rust_analyzer.py: avoid FD leak
Use `pathlib.Path.read_text()` to avoid leaking file descriptors. Fixes: 8c4555c ("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>
1 parent 36c619f commit 9b4744d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scripts/generate_rust_analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,10 @@ def append_crate_with_generated(
313313

314314
def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
315315
try:
316-
return f"{target}.o" in open(build_file).read()
316+
contents = build_file.read_text()
317317
except FileNotFoundError:
318318
return False
319+
return f"{target}.o" in contents
319320

320321
# Then, the rest outside of `rust/`.
321322
#

0 commit comments

Comments
 (0)