Skip to content

Commit 64f3e49

Browse files
committed
refactor(port_std): inline format args
Ditto.
1 parent 721f2d5 commit 64f3e49

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

src/r3_port_std/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl TaskState {
169169
}
170170

171171
unsafe fn exit_and_dispatch<Traits: PortInstance>(&self, state: &'static State) -> ! {
172-
log::trace!("exit_and_dispatch({:p}) enter", self);
172+
log::trace!("exit_and_dispatch({self:p}) enter");
173173
self.assert_current_thread();
174174

175175
let mut lock = state.thread_group.get().unwrap().lock();
@@ -196,7 +196,7 @@ impl TaskState {
196196
// Invoke the dispatcher
197197
unsafe { state.yield_cpu::<Traits>() };
198198

199-
log::trace!("exit_and_dispatch({:p}) calling exit_thread", self);
199+
log::trace!("exit_and_dispatch({self:p}) calling exit_thread");
200200
unsafe { ums::exit_thread() };
201201
}
202202
}
@@ -260,7 +260,7 @@ impl State {
260260
<Traits as PortToKernel>::boot();
261261
}
262262
});
263-
log::trace!("startup thread = {:?}", thread_id);
263+
log::trace!("startup thread = {thread_id:?}");
264264
lock.scheduler().task_thread = Some(thread_id);
265265
lock.scheduler().recycle_thread(thread_id);
266266
lock.preempt();
@@ -346,7 +346,7 @@ impl State {
346346
// there's no data race
347347
let running_task = unsafe { *Traits::state().running_task_ptr() };
348348
lock.scheduler().task_thread = if let Some(task) = running_task {
349-
log::trace!("dispatching task {:p}", task);
349+
log::trace!("dispatching task {task:p}");
350350

351351
let mut tsm = task.port_task_state.tsm.lock();
352352

@@ -357,7 +357,7 @@ impl State {
357357
THREAD_ROLE.with(|role| role.set(ThreadRole::Task));
358358
assert!(!self.is_cpu_lock_active::<Traits>());
359359

360-
log::debug!("task {:p} is now running", task);
360+
log::debug!("task {task:p} is now running");
361361

362362
// Safety: The port can call this
363363
unsafe {
@@ -373,7 +373,7 @@ impl State {
373373
}
374374
});
375375

376-
log::trace!("spawned thread {:?} for the task {:p}", thread, task);
376+
log::trace!("spawned thread {thread:?} for the task {task:p}");
377377

378378
*tsm = Tsm::Running(thread);
379379
Some(thread)
@@ -435,7 +435,7 @@ impl State {
435435
&self,
436436
task: &'static TaskCb<Traits>,
437437
) {
438-
log::trace!("initialize_task_state {:p}", task);
438+
log::trace!("initialize_task_state {task:p}");
439439
expect_worker_thread::<Traits>();
440440
assert!(self.is_cpu_lock_active::<Traits>());
441441

@@ -495,7 +495,7 @@ impl State {
495495
num: InterruptNum,
496496
priority: InterruptPriority,
497497
) -> Result<(), SetInterruptLinePriorityError> {
498-
log::trace!("set_interrupt_line_priority{:?}", (num, priority));
498+
log::trace!("set_interrupt_line_priority({num}, {priority})");
499499
assert!(matches!(
500500
expect_worker_thread::<Traits>(),
501501
ThreadRole::Boot | ThreadRole::Task
@@ -518,7 +518,7 @@ impl State {
518518
&'static self,
519519
num: InterruptNum,
520520
) -> Result<(), EnableInterruptLineError> {
521-
log::trace!("enable_interrupt_line{:?}", (num,));
521+
log::trace!("enable_interrupt_line({num})");
522522
expect_worker_thread::<Traits>();
523523

524524
let mut lock = self.thread_group.get().unwrap().lock();
@@ -538,7 +538,7 @@ impl State {
538538
&self,
539539
num: InterruptNum,
540540
) -> Result<(), EnableInterruptLineError> {
541-
log::trace!("disable_interrupt_line{:?}", (num,));
541+
log::trace!("disable_interrupt_line({num})");
542542
expect_worker_thread::<Traits>();
543543

544544
(self.thread_group.get().unwrap().lock())
@@ -551,7 +551,7 @@ impl State {
551551
&'static self,
552552
num: InterruptNum,
553553
) -> Result<(), PendInterruptLineError> {
554-
log::trace!("pend_interrupt_line{:?}", (num,));
554+
log::trace!("pend_interrupt_line({num})");
555555
expect_worker_thread::<Traits>();
556556

557557
let mut lock = self.thread_group.get().unwrap().lock();
@@ -571,7 +571,7 @@ impl State {
571571
&self,
572572
num: InterruptNum,
573573
) -> Result<(), ClearInterruptLineError> {
574-
log::trace!("clear_interrupt_line{:?}", (num,));
574+
log::trace!("clear_interrupt_line({num})");
575575
expect_worker_thread::<Traits>();
576576

577577
(self.thread_group.get().unwrap().lock())
@@ -647,7 +647,7 @@ impl State {
647647

648648
pub fn pend_tick_after<Traits: PortInstance>(&self, tick_count_delta: UTicks) {
649649
expect_worker_thread::<Traits>();
650-
log::trace!("pend_tick_after({:?})", tick_count_delta);
650+
log::trace!("pend_tick_after({tick_count_delta:?})");
651651

652652
// Calculate when `timer_tick` should be called
653653
let now = Instant::now() + Duration::from_micros(tick_count_delta.into());
@@ -713,7 +713,7 @@ pub fn shutdown<Traits: PortInstance>() {
713713
pub fn pend_interrupt_line<Traits: PortInstance>(
714714
num: InterruptNum,
715715
) -> Result<(), PendInterruptLineError> {
716-
log::trace!("external-pend_interrupt_line{:?}", (num,));
716+
log::trace!("external-pend_interrupt_line({num})");
717717

718718
assert_eq!(
719719
THREAD_ROLE.with(|r| r.get()),

src/r3_port_std/src/sched.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ impl ums::Scheduler for SchedState {
124124
fn thread_exited(&mut self, thread_id: ums::ThreadId) {
125125
let Some(i) = self.zombies.iter().position(|id| *id == thread_id)
126126
else {
127-
log::warn!("thread_exited: unexpected thread {:?}", thread_id);
127+
log::warn!("thread_exited: unexpected thread {thread_id:?}");
128128
return;
129129
};
130130

131-
log::trace!("removing the zombie thread {:?}", thread_id);
131+
log::trace!("removing the zombie thread {thread_id:?}");
132132
self.zombies.swap_remove(i);
133133
}
134134
}
@@ -162,21 +162,16 @@ pub fn check_preemption_by_interrupt(
162162

163163
// Masking by CPU Lock
164164
if sched_state.cpu_lock && is_interrupt_priority_managed(pri) {
165-
log::trace!(
166-
"not handling an interrupt with priority {} because of CPU Lock",
167-
pri
168-
);
165+
log::trace!("not handling an interrupt with priority {pri} because of CPU Lock");
169166
break;
170167
}
171168

172169
// Masking by an already active interrupt
173170
if let Some(&(existing_pri, _)) = sched_state.active_int_handlers.last() {
174171
if existing_pri < pri {
175172
log::trace!(
176-
"not handling an interrupt with priority {} because of \
177-
an active interrupt handler with priority {}",
178-
pri,
179-
existing_pri,
173+
"not handling an interrupt with priority {pri} because of \
174+
an active interrupt handler with priority {existing_pri}",
180175
);
181176
break;
182177
}
@@ -204,24 +199,15 @@ pub fn check_preemption_by_interrupt(
204199
// Make this interrupt handler inactive
205200
let (_, popped_thread_id) = lock.scheduler().active_int_handlers.pop().unwrap();
206201
assert_eq!(thread_id, popped_thread_id);
207-
log::trace!(
208-
"an interrupt handler for an interrupt {} (priority = {}) exited",
209-
num,
210-
pri
211-
);
202+
log::trace!("an interrupt handler for an interrupt {num} (priority = {pri}) exited");
212203

213204
// Make sure this thread will run to completion
214205
lock.scheduler().zombies.push(thread_id);
215206

216207
let _ = check_preemption_by_interrupt(thread_group, &mut lock);
217208
});
218209

219-
log::trace!(
220-
"handling an interrupt {} (priority = {}) with thread {:?}",
221-
num,
222-
pri,
223-
thread_id
224-
);
210+
log::trace!("handling an interrupt {num} (priority = {pri}) with thread {thread_id:?}");
225211

226212
lock.scheduler().active_int_handlers.push((pri, thread_id));
227213

src/r3_port_std/src/ums.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'a, Sched: Scheduler> ThreadGroupLockGuard<'a, Sched> {
173173
// Save the `JoinHandle` representing the spawned thread
174174
self.guard.threads[ptr].join_handle = Some(join_handle);
175175

176-
log::trace!("created {:?}", thread_id);
176+
log::trace!("created {thread_id:?}");
177177

178178
thread_id
179179
}
@@ -307,7 +307,7 @@ fn finalize_thread(
307307
thread_id: ThreadId,
308308
result: Result<()>,
309309
) {
310-
log::trace!("{:?} exited with result {:?}", thread_id, result);
310+
log::trace!("{thread_id:?} exited with result {result:?}");
311311

312312
// Delete the current thread
313313
let mut state_guard = thread_group.lock().unwrap();

0 commit comments

Comments
 (0)