From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH 4/4] common: common_console: Rework log_print
Date: Thu, 25 Mar 2021 14:38:37 +0100 [thread overview]
Message-ID: <20210325133837.30866-4-jmaselbas@kalray.eu> (raw)
In-Reply-To: <20210325133837.30866-1-jmaselbas@kalray.eu>
Since time_beginning has been removed there is no reason to use a
variables called `diff` or `diff_ul`, there are respectively renamed
to `time_ns` and `time`.
Also remove the test for null timestamp.
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
common/console_common.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/common/console_common.c b/common/console_common.c
index 7e9973ed8..1e4bf87b1 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -188,8 +188,8 @@ void log_print(unsigned flags, unsigned levels)
unsigned long last = 0;
list_for_each_entry(log, &barebox_logbuf, list) {
- uint64_t diff = log->timestamp;
- unsigned long difful;
+ uint64_t time_ns = log->timestamp;
+ unsigned long time;
if (levels && !(levels & (1 << log->level)))
continue;
@@ -201,21 +201,19 @@ void log_print(unsigned flags, unsigned levels)
if (flags & BAREBOX_LOG_PRINT_RAW)
printf("<%i>", log->level);
- do_div(diff, 1000);
- difful = diff;
-
- if (!log->timestamp)
- difful = 0;
+ /* convert ns to us */
+ do_div(time_ns, 1000);
+ time = time_ns;
if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
printf("[");
if (flags & BAREBOX_LOG_PRINT_TIME)
- printf("%10luus", difful);
+ printf("%10luus", time);
if (flags & BAREBOX_LOG_DIFF_TIME) {
- printf(" < %10luus", difful - last);
- last = difful;
+ printf(" < %10luus", time - last);
+ last = time;
}
if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2021-03-25 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-25 13:38 [PATCH 1/4] clock: Change cyc2ns return type to uint64_t Jules Maselbas
2021-03-25 13:38 ` [PATCH 2/4] clock: Update cs->cycle_last when switching clock Jules Maselbas
2021-03-25 13:38 ` [PATCH 3/4] clock: Remove time_beginning Jules Maselbas
2021-03-25 13:38 ` Jules Maselbas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210325133837.30866-4-jmaselbas@kalray.eu \
--to=jmaselbas@kalray.eu \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox