[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <15D9DEFA-12F6-4632-979E-F67C7315E95F@collabora.com>
Date: Tue, 25 Mar 2025 11:06:59 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Tamir Duberstein <tamird@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
Boris-Chengbiao Zhou <bobo1239@....de>,
Kees Cook <kees@...nel.org>,
Fiona Behrens <me@...enk.dev>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
Lukas Wirth <lukas.wirth@...rous-systems.com>
Subject: Re: [PATCH v4 09/11] scripts: generate_rust_analyzer.py: avoid FD
leak
> On 22 Mar 2025, at 10:23, Tamir Duberstein <tamird@...il.com> wrote:
>
> Use a context manager to avoid leaking file descriptors.
>
> Signed-off-by: Tamir Duberstein <tamird@...il.com>
> ---
> scripts/generate_rust_analyzer.py | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index bd6e321a6aa5..ccb15aa66929 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -211,7 +211,8 @@ def generate_crates(
>
> def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
> try:
> - return f"{target}.o" in open(build_file).read()
> + with open(build_file) as f:
> + return f"{target}.o" in f.read()
> except FileNotFoundError:
> return False
>
>
> --
> 2.48.1
>
>
Oh, nice!
Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>
Powered by blists - more mailing lists