logging: log_output: move partly unused code

move code, that is only needed for one case
to that case.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2024-12-09 15:39:10 +01:00 committed by Benjamin Cabé
commit 5d2068f491

View file

@ -163,19 +163,11 @@ static int timestamp_print(const struct log_output *output,
uint64_t total_seconds; uint64_t total_seconds;
#endif #endif
uint32_t remainder; uint32_t remainder;
uint32_t seconds;
uint32_t hours;
uint32_t mins;
uint32_t ms; uint32_t ms;
uint32_t us; uint32_t us;
timestamp /= timestamp_div; timestamp /= timestamp_div;
total_seconds = timestamp / freq; total_seconds = timestamp / freq;
seconds = total_seconds;
hours = seconds / 3600U;
seconds -= hours * 3600U;
mins = seconds / 60U;
seconds -= mins * 60U;
remainder = timestamp % freq; remainder = timestamp % freq;
ms = (remainder * 1000U) / freq; ms = (remainder * 1000U) / freq;
@ -258,6 +250,15 @@ static int timestamp_print(const struct log_output *output,
#endif /* CONFIG_REQUIRES_FULL_LIBC */ #endif /* CONFIG_REQUIRES_FULL_LIBC */
#endif /* CONFIG_POSIX_C_LANG_SUPPORT_R */ #endif /* CONFIG_POSIX_C_LANG_SUPPORT_R */
} else { } else {
uint32_t seconds;
uint32_t hours;
uint32_t mins;
seconds = total_seconds;
hours = seconds / 3600U;
seconds -= hours * 3600U;
mins = seconds / 60U;
seconds -= mins * 60U;
length = print_formatted(output, length = print_formatted(output,
"[%02u:%02u:%02u.%03u,%03u] ", "[%02u:%02u:%02u.%03u,%03u] ",
hours, mins, seconds, ms, us); hours, mins, seconds, ms, us);