[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <43490b38-5d8c-4dfc-a37a-8f34f99e2d3c@lunn.ch>
Date: Fri, 19 Sep 2025 17:16:17 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>,
Trevor Gross <tmgross@...ch.edu>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
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 <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Danilo Krummrich <dakr@...nel.org>, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] rust: net::phy inline if expressions to improve
read_status
> There's obviously nothing wrong with local variables. This patch is not
> about performance improvements, but writing consistent and idiomatic
> Rust code.
>
> Currently, dev.set_duplex() uses a local variable and is called once,
> whereas dev.set_speed() doesn't use a local variable and is called
> twice.
I would suggest the opposite change if you want to make the code
consistent:
let speed = if ret & BMCR_SPEED100 != 0 {
uapi::SPEED_100
} else {
uapi::SPEED_10
}
dev.set_speed(speed)
Andrew
Powered by blists - more mailing lists