linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk.c: removed unnecessary code
@ 2016-11-29 15:19 Sebastian Duda
  2016-11-30  9:14 ` Michal Hocko
  2016-12-01 17:12 ` [lkp] [printk.c] ea0639c4d5: BUG:recent_printk_recursion kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Duda @ 2016-11-29 15:19 UTC (permalink / raw)
  Cc: linux-kernel, Sebastian Duda, Tobias Baumeister, Andrew Morton,
	Petr Mladek, Sergey Senozhatsky, Borislav Petkov, Tejun Heo,
	Thierry Reding, open list

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-02 10:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 15:19 [PATCH] printk.c: removed unnecessary code Sebastian Duda
2016-11-30  9:14 ` 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

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).