Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <richard120310@gmail.com>
Link: https://lore.kernel.org/r/20250310073853.427954-1-richard120310@gmail.com
Reviewed-by: Benno Lossin <lossin@kernel.org>
[ Rebased dropping the cases that do not apply anymore. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

I Hsin Cheng and committed by
Miguel Ojeda
28669b2f 249c3a0e

+2 -2
+2 -2
rust/kernel/list.rs
··· 319 319 320 320 /// Removes the last item from this list. 321 321 pub fn pop_back(&mut self) -> Option<ListArc<T, ID>> { 322 - if self.first.is_null() { 322 + if self.is_empty() { 323 323 return None; 324 324 } 325 325 ··· 331 331 332 332 /// Removes the first item from this list. 333 333 pub fn pop_front(&mut self) -> Option<ListArc<T, ID>> { 334 - if self.first.is_null() { 334 + if self.is_empty() { 335 335 return None; 336 336 } 337 337