All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: zhe.he@windriver.com
Cc: pmladek@suse.com, sergey.senozhatsky@gmail.com,
	rostedt@goodmis.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] printk: Add KBUILD_MODNAME and correct bare use of unsigned
Date: Wed, 19 Sep 2018 11:06:21 +0900	[thread overview]
Message-ID: <20180919020621.GA390@jagdpanzerIV> (raw)
In-Reply-To: <1537291068-443145-2-git-send-email-zhe.he@windriver.com>

On (09/19/18 01:17), zhe.he@windriver.com wrote:
> Add KBUILD_MODNAME to make prints more clear.

No strong opinion. I'm OK with this change.

> And use 'unsigned int' intead of 'unsigned' according to
> checkpatch.pl's suggestion.

I don't think that "unsigned int" is the right thing to use there.

>  		if (console_seq < log_first_seq) {
>  			len = sprintf(text, "** %u printk messages dropped **\n",
> -				      (unsigned)(log_first_seq - console_seq));
> +				   (unsigned int)(log_first_seq - console_seq));

Both log_first_seq and console_seq are u64.

	log_first_seq - console_seq

thus, *in theory*, can be larger than "unsigned int". So I'd just avoid cast
and use an appropriate for u64 %llu sprintf() specifier. Something like below,
perhaps:

---

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f73ea9dd6f46..4b8c5832bf14 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2408,8 +2408,9 @@ void console_unlock(void)
 		printk_safe_enter_irqsave(flags);
 		raw_spin_lock(&logbuf_lock);
 		if (console_seq < log_first_seq) {
-			len = sprintf(text, "** %u printk messages dropped **\n",
-				   (unsigned int)(log_first_seq - console_seq));
+			len = sprintf(text,
+				      "** %llu printk messages dropped **\n",
+				      log_first_seq - console_seq);
 
 			/* messages are gone, move to first one */
 			console_seq = log_first_seq;

---

Steven, Petr, any objections?

	-ss

  reply	other threads:[~2018-09-19  2:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 17:17 [PATCH v2 1/2] printk: Fix panic caused by passing log_buf_len to command line zhe.he
2018-09-18 17:17 ` [PATCH v2 2/2] printk: Add KBUILD_MODNAME and correct bare use of unsigned zhe.he
2018-09-19  2:06   ` Sergey Senozhatsky [this message]
2018-09-19 11:20     ` Petr Mladek
2018-09-19  1:50 ` [PATCH v2 1/2] printk: Fix panic caused by passing log_buf_len to command line Sergey Senozhatsky
2018-09-19  2:27   ` He Zhe
2018-09-19  2:39     ` Sergey Senozhatsky
2018-09-19  2:43       ` Steven Rostedt
2018-09-19  2:47         ` Sergey Senozhatsky
2018-09-19  3:05           ` Steven Rostedt
2018-09-20 16:16         ` He Zhe
2018-09-20 16:30           ` Steven Rostedt
2018-09-21  7:37             ` Petr Mladek
2018-09-22 15:36               ` He Zhe
2018-09-25 12:16                 ` Sergey Senozhatsky
2018-09-25 12:01               ` Sergey Senozhatsky
2018-09-25 12:23                 ` Petr Mladek
2018-09-25 12:37                   ` Sergey Senozhatsky
2018-09-25 13:31                   ` Sergey Senozhatsky
2018-09-25 15:31                     ` He Zhe
2018-09-26 11:05                     ` Petr Mladek
2018-09-28  7:35                       ` Sergey Senozhatsky
2018-09-28  8:22                         ` He Zhe
2018-09-19  6:44     ` Sergey Senozhatsky
2018-09-19 10:09       ` He Zhe
2018-09-19 18:58 ` Sasha Levin
2018-09-22 14:45   ` He Zhe

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=20180919020621.GA390@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=zhe.he@windriver.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.