From: I Hsin Cheng Date: Mon, 10 Mar 2025 07:38:52 +0000 (+0800) Subject: rust: list: Use "List::is_empty()" to perform checking when possible X-Git-Tag: v6.16-rc1~45^2~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28669b2f37e9b7e98b62d0be2e10a5bf31c2b16f;p=thirdparty%2Fkernel%2Fstable.git rust: list: Use "List::is_empty()" to perform checking when possible "List::is_empty()" provides a straight forward convention to check whether a given "List" is empty or not. There're numerous places in the current implementation still use "self.first.is_null()" to perform the equivalent check, replace them with "List::is_empty()". Signed-off-by: I Hsin Cheng Link: https://lore.kernel.org/r/20250310073853.427954-1-richard120310@gmail.com Reviewed-by: Benno Lossin [ Rebased dropping the cases that do not apply anymore. - Miguel ] Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/list.rs b/rust/kernel/list.rs index a335c3b1ff5e4..7740c8f16cf6a 100644 --- a/rust/kernel/list.rs +++ b/rust/kernel/list.rs @@ -319,7 +319,7 @@ impl, const ID: u64> List { /// Removes the last item from this list. pub fn pop_back(&mut self) -> Option> { - if self.first.is_null() { + if self.is_empty() { return None; } @@ -331,7 +331,7 @@ impl, const ID: u64> List { /// Removes the first item from this list. pub fn pop_front(&mut self) -> Option> { - if self.first.is_null() { + if self.is_empty() { return None; }