scripts: generate_rust_analyzer.py: avoid FD leak

Use `pathlib.Path.read_text()` to avoid leaking file descriptors.

Fixes: 8c4555ccc5 ("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>
This commit is contained in:
Tamir Duberstein 2026-01-27 11:35:43 -05:00
parent 36c619f6bd
commit 9b4744d8ed
No known key found for this signature in database
GPG Key ID: D04C0E2517D71297

View File

@ -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/`.
#