From 7b9dc107a80a8f4c287c2df4ffc2a82dec7af773 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 17 Apr 2017 10:26:47 -0500 Subject: [PATCH] kernel: Convert formatter strings to use PRI defines To allow for various libc implementations (like newlib) in which the way various {u}int{8,16,32}_t types are defined vary between both libc implementations and across architectures we need to utilize the PRI defines. Change-Id: Ie884fb67015502288152ecbd64c37961a4f538e4 Signed-off-by: Kumar Gala --- kernel/include/ksched.h | 8 +++++--- kernel/include/timeout_q.h | 2 +- kernel/int_latency_bench.c | 12 ++++++------ kernel/mutex.c | 7 ++++--- kernel/sched.c | 10 +++++----- kernel/sys_clock.c | 4 ++-- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 3a5bb9cc539..f85fc205f9a 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -241,7 +241,7 @@ static inline void _sched_lock(void) compiler_barrier(); - K_DEBUG("scheduler locked (%p:%d)\n", + K_DEBUG("scheduler locked (%p:%" PRIu8 ")\n", _current, _current->base.sched_locked); #endif } @@ -391,13 +391,15 @@ static inline void _ready_thread(struct k_thread *thread) __ASSERT(_is_prio_higher(thread->base.prio, K_LOWEST_THREAD_PRIO) || ((thread->base.prio == K_LOWEST_THREAD_PRIO) && (thread == _idle_thread)), - "thread %p prio too low (is %d, cannot be lower than %d)", + "thread %p prio too low (is %" PRId8 ", " + "cannot be lower than %d)", thread, thread->base.prio, thread == _idle_thread ? K_LOWEST_THREAD_PRIO : K_LOWEST_APPLICATION_THREAD_PRIO); __ASSERT(!_is_prio_higher(thread->base.prio, K_HIGHEST_THREAD_PRIO), - "thread %p prio too high (id %d, cannot be higher than %d)", + "thread %p prio too high (id %" PRId8 ", " + "cannot be higher than %d)", thread, thread->base.prio, K_HIGHEST_THREAD_PRIO); /* needed to handle the start-with-delay case */ diff --git a/kernel/include/timeout_q.h b/kernel/include/timeout_q.h index 291e32d700f..b508e9f1409 100644 --- a/kernel/include/timeout_q.h +++ b/kernel/include/timeout_q.h @@ -148,7 +148,7 @@ static inline void _dump_timeout(struct _timeout *timeout, int extra_tab) K_DEBUG("%stimeout %p, prev: %p, next: %p\n" "%s\tthread: %p, wait_q: %p\n" - "%s\tticks remaining: %d\n" + "%s\tticks remaining: %" PRId32 "\n" "%s\tfunction: %p\n", tab, timeout, timeout->node.prev, timeout->node.next, tab, timeout->thread, timeout->wait_q, diff --git a/kernel/int_latency_bench.c b/kernel/int_latency_bench.c index 0a09d9bb98a..bf9d23c6c46 100644 --- a/kernel/int_latency_bench.c +++ b/kernel/int_latency_bench.c @@ -190,22 +190,22 @@ void int_latency_show(void) } else { intHandlerLatency = _hw_irq_to_c_handler_latency; printk(" Min latency from hw interrupt up to 'C' int. " - "handler:" - " %d tcs = %d nsec\n", + "handler: " + " %" PRIu32 " tcs = %" PRIu32 " nsec\n", intHandlerLatency, SYS_CLOCK_HW_CYCLES_TO_NS(intHandlerLatency)); } printk(" Max interrupt latency (includes hw int. to 'C' " "handler):" - " %d tcs = %d nsec\n", + " %" PRIu32 " tcs = %" PRIu32 " nsec\n", int_locked_latency_max + intHandlerLatency, SYS_CLOCK_HW_CYCLES_TO_NS(int_locked_latency_max + intHandlerLatency)); printk(" Overhead substracted from Max int. latency:\n" - " for int. lock : %d tcs = %d nsec\n" - " each time int. lock nest: %d tcs = %d nsec\n" - " for int. unlocked : %d tcs = %d nsec\n", + " for int. lock : %" PRIu32 " tcs = %" PRIu32 " nsec\n" + " each time int. lock nest: %" PRIu32 " tcs = %" PRIu32 " nsec\n" + " for int. unlocked : %" PRIu32 " tcs = %" PRIu32 " nsec\n", initial_start_delay, SYS_CLOCK_HW_CYCLES_TO_NS(initial_start_delay), nesting_delay, diff --git a/kernel/mutex.c b/kernel/mutex.c index cb510fc71e2..2ac11417c2e 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -92,7 +92,8 @@ static void adjust_owner_prio(struct k_mutex *mutex, int new_prio) { if (mutex->owner->base.prio != new_prio) { - K_DEBUG("%p (ready (y/n): %c) prio changed to %d (was %d)\n", + K_DEBUG("%p (ready (y/n): %c) prio changed to %d " + "(was %" PRId8 ")\n", mutex->owner, _is_thread_ready(mutex->owner) ? 'y' : 'n', new_prio, mutex->owner->base.prio); @@ -118,7 +119,7 @@ int k_mutex_lock(struct k_mutex *mutex, int32_t timeout) mutex->lock_count++; mutex->owner = _current; - K_DEBUG("%p took mutex %p, count: %d, orig prio: %d\n", + K_DEBUG("%p took mutex %p, count: %" PRIu32 ", orig prio: %d\n", _current, mutex, mutex->lock_count, mutex->owner_orig_prio); @@ -200,7 +201,7 @@ void k_mutex_unlock(struct k_mutex *mutex) mutex->lock_count--; - K_DEBUG("mutex %p lock_count: %d\n", mutex, mutex->lock_count); + K_DEBUG("mutex %p lock_count: %" PRIu32 "\n", mutex, mutex->lock_count); if (mutex->lock_count != 0) { k_sched_unlock(); diff --git a/kernel/sched.c b/kernel/sched.c index e2da289975c..b74c655c813 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -147,7 +147,7 @@ void k_sched_lock(void) */ compiler_barrier(); - K_DEBUG("scheduler locked (%p:%d)\n", + K_DEBUG("scheduler locked (%p:%" PRIu8 ")\n", _current, _current->base.sched_locked); #endif } @@ -164,7 +164,7 @@ void k_sched_unlock(void) ++_current->base.sched_locked; - K_DEBUG("scheduler unlocked (%p:%d)\n", + K_DEBUG("scheduler unlocked (%p:%" PRIu8 ")\n", _current, _current->base.sched_locked); _reschedule_threads(key); @@ -228,7 +228,7 @@ void _pend_current_thread(_wait_q_t *wait_q, int32_t timeout) int __must_switch_threads(void) { #ifdef CONFIG_PREEMPT_ENABLED - K_DEBUG("current prio: %d, highest prio: %d\n", + K_DEBUG("current prio: %" PRId8 ", highest prio: %d\n", _current->base.prio, _get_highest_ready_prio()); extern void _dump_ready_q(void); @@ -314,7 +314,7 @@ void k_sleep(int32_t duration) __ASSERT(!_is_in_isr(), ""); __ASSERT(duration != K_FOREVER, ""); - K_DEBUG("thread %p for %d ns\n", _current, duration); + K_DEBUG("thread %p for %" PRId32 " ns\n", _current, duration); /* wait of 0 ms is treated as a 'yield' */ if (duration == 0) { @@ -366,7 +366,7 @@ void _dump_ready_q(void) { K_DEBUG("bitmaps: "); for (int bitmap = 0; bitmap < K_NUM_PRIO_BITMAPS; bitmap++) { - K_DEBUG("%x", _ready_q.prio_bmap[bitmap]); + K_DEBUG("%" PRIx32, _ready_q.prio_bmap[bitmap]); } K_DEBUG("\n"); for (int prio = 0; prio < K_NUM_PRIORITIES; prio++) { diff --git a/kernel/sys_clock.c b/kernel/sys_clock.c index fd70324ecdd..dcb62332a21 100644 --- a/kernel/sys_clock.c +++ b/kernel/sys_clock.c @@ -201,7 +201,7 @@ static inline void handle_timeouts(int32_t ticks) struct _timeout *head = (struct _timeout *)sys_dlist_peek_head(&_timeout_q); - K_DEBUG("head: %p, delta: %d\n", + K_DEBUG("head: %p, delta: %" PRId32 "\n", head, head ? head->delta_ticks_from_prev : -2112); if (!head) { @@ -311,7 +311,7 @@ void _nano_sys_clock_tick_announce(int32_t ticks) { unsigned int key; - K_DEBUG("ticks: %d\n", ticks); + K_DEBUG("ticks: %" PRId32 "\n", ticks); /* 64-bit value, ensure atomic access with irq lock */ key = irq_lock();