Skip to content

Commit 3ce761b

Browse files
committed
refactor: replace <_>::max_value() with <_>::MAX
The `<_>::max_value()` methods are soft-deprecated.
1 parent aa51fb9 commit 3ce761b

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/constance/src/kernel/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ impl<System> CfgBuilder<System> {
536536
panic!("`num_task_priority_levels` must be greater than zero");
537537
} else if new_value > FIXED_PRIO_BITMAP_MAX_LEN {
538538
panic!("`num_task_priority_levels` must be less than or equal to `FIXED_PRIO_BITMAP_MAX_LEN`");
539-
} else if new_value >= isize::max_value() as usize {
540-
// Limiting priority values in range `0..(isize::max_value() - 1)`
539+
} else if new_value >= isize::MAX as usize {
540+
// Limiting priority values in range `0..(isize::MAX - 1)`
541541
// leaves room for special values outside the extremities.
542542
//
543543
// This branch is actually unreachable because

src/constance/src/kernel/task.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,15 @@ pub(super) fn unlock_cpu_and_check_preemption<System: Kernel>(lock: utils::CpuLo
553553
let prev_task_priority = if let Some(running_task) = System::state().running_task() {
554554
running_task.priority.to_usize().unwrap()
555555
} else {
556-
usize::max_value()
556+
usize::MAX
557557
};
558558

559559
// The priority of the next task to run
560560
let next_task_priority = System::state()
561561
.task_ready_bitmap
562562
.read(&*lock)
563563
.find_set()
564-
.unwrap_or(usize::max_value());
564+
.unwrap_or(usize::MAX);
565565

566566
// Relinquish CPU Lock
567567
drop(lock);
@@ -593,30 +593,30 @@ pub(super) fn choose_next_running_task<System: Kernel>(
593593
if *running_task.st.read(&*lock) == TaskSt::Running {
594594
running_task.priority.to_usize().unwrap()
595595
} else {
596-
usize::max_value()
596+
usize::MAX
597597
}
598598
} else {
599-
usize::max_value()
599+
usize::MAX
600600
};
601601

602602
// The priority of the next task to run
603603
//
604-
// The default value is `usize::max_value() - 1` for the following reason:
604+
// The default value is `usize::MAX - 1` for the following reason:
605605
// If `running_task` is in the Waiting state and there's no other task to
606606
// schedule at the moment, we want to assign `None` to `running_task`. In
607607
// this case, if the default value was the same as `prev_task_priority`,
608608
// `prev_task_priority` would be equal to `next_task_priority`, and the
609609
// `if` statement below would return too early. We make sure this does not
610610
// happen by making the default value of `next_task_priority` lower.
611611
//
612-
// `usize::max_value()` never collides with an actual task priority because
612+
// `usize::MAX - 1` never collides with an actual task priority because
613613
// of the priority range restriction imposed by `CfgBuilder::
614614
// num_task_priority_levels`.
615615
let next_task_priority = System::state()
616616
.task_ready_bitmap
617617
.read(&*lock)
618618
.find_set()
619-
.unwrap_or(usize::max_value() - 1);
619+
.unwrap_or(usize::MAX - 1);
620620

621621
// Return if there's no task willing to take over the current one, and
622622
// the current one can still run.

src/constance/src/utils/int.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use super::{Init, ZeroInit};
66
/// Get the smallest unsigned integer type capable of representing the specified
77
/// value.
88
pub type UIntegerWithBound<const MAX: u128> = If! {
9-
if (MAX <= u8::max_value() as u128) {
9+
if (MAX <= u8::MAX as u128) {
1010
u8
11-
} else if (MAX <= u16::max_value() as u128) {
11+
} else if (MAX <= u16::MAX as u128) {
1212
u16
13-
} else if (MAX <= u32::max_value() as u128) {
13+
} else if (MAX <= u32::MAX as u128) {
1414
u32
15-
} else if (MAX <= u64::max_value() as u128) {
15+
} else if (MAX <= u64::MAX as u128) {
1616
u64
1717
} else {
1818
u128

src/constance_port_std/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ macro_rules! use_port {
779779

780780
unsafe impl PortInterrupts for $sys {
781781
const MANAGED_INTERRUPT_PRIORITY_RANGE:
782-
::std::ops::Range<InterruptPriority> = 0..InterruptPriority::max_value();
782+
::std::ops::Range<InterruptPriority> = 0..InterruptPriority::MAX;
783783

784784
unsafe fn set_interrupt_line_priority(
785785
line: InterruptNum,

src/constance_port_std/src/utils/iterpool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl PoolPtr {
9191

9292
/// Construct a `PoolPtr` from a given `x: usize`.
9393
///
94-
/// `x` must be less than `usize::max_value()`.
94+
/// `x` must be less than `usize::MAX`.
9595
pub fn new(x: usize) -> Self {
9696
PoolPtr(NonZeroUsize::new(x.wrapping_add(1)).expect("count overflow"))
9797
}

0 commit comments

Comments
 (0)