From: Sebastian Duda <sebastian.duda@fau.de>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-kernel@i4.cs.fau.de, Sebastian Duda <sebastian.duda@fau.de>,
Tobias Baumeister <tobias.baumeister@fau.de>,
Andrew Morton <akpm@linux-foundation.org>,
Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Borislav Petkov <bp@suse.de>, Tejun Heo <tj@kernel.org>,
Thierry Reding <treding@nvidia.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] printk.c: removed unnecessary code
Date: Tue, 29 Nov 2016 16:19:01 +0100 [thread overview]
Message-ID: <1480432743-8049-1-git-send-email-sebastian.duda@fau.de> (raw)
snprintf((char *) ?, 0, ...); always returns Zero and doesn't change the data.
Thus the execution of
snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
has no effect on program.
The substitution with 0 increases the readability of the code.
Signed-off-by: Sebastian Duda <sebastian.duda@fau.de>
Signed-off-by: Tobias Baumeister <tobias.baumeister@fau.de>
---
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5028f4f..fe3fec1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1186,7 +1186,7 @@ static size_t print_time(u64 ts, char *buf)
rem_nsec = do_div(ts, 1000000000);
if (!buf)
- return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
+ return 0;
return sprintf(buf, "[%5lu.%06lu] ",
(unsigned long)ts, rem_nsec / 1000);
--
2.7.4
next reply other threads:[~2016-11-29 15:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 15:19 Sebastian Duda [this message]
2016-11-30 9:14 ` [PATCH] printk.c: removed unnecessary code Michal Hocko
2016-11-30 10:22 ` Petr Mladek
2016-12-01 17:12 ` [lkp] [printk.c] ea0639c4d5: BUG:recent_printk_recursion kernel test robot
2016-12-02 10:05 ` Petr Mladek
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=1480432743-8049-1-git-send-email-sebastian.duda@fau.de \
--to=sebastian.duda@fau.de \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=linux-kernel@i4.cs.fau.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tj@kernel.org \
--cc=tobias.baumeister@fau.de \
--cc=treding@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).