Skip to content

Commit

Permalink
lib/math: avoid trailing newline hidden in pr_fmt()
Browse files Browse the repository at this point in the history
pr_xxx() functions usually have a newline at the end of the logging
message.

Here, this newline is added via the 'pr_fmt' macro.

In order to be more consistent with other files, use a more standard
convention and put these newlines back in the messages themselves and
remove it from the pr_fmt macro.

While at it, use __func__ instead of hardcoding a function name in the
last message.

Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
tititiou36 authored and torvalds committed Jun 5, 2020
1 parent e33c9fe commit 9ac1757
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/math/prime_numbers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
#define pr_fmt(fmt) "prime numbers: " fmt "\n"
#define pr_fmt(fmt) "prime numbers: " fmt

#include <linux/module.h>
#include <linux/mutex.h>
Expand Down Expand Up @@ -253,7 +253,7 @@ static void dump_primes(void)

if (buf)
bitmap_print_to_pagebuf(true, buf, p->primes, p->sz);
pr_info("primes.{last=%lu, .sz=%lu, .primes[]=...x%lx} = %s",
pr_info("primes.{last=%lu, .sz=%lu, .primes[]=...x%lx} = %s\n",
p->last, p->sz, p->primes[BITS_TO_LONGS(p->sz) - 1], buf);

rcu_read_unlock();
Expand All @@ -273,7 +273,7 @@ static int selftest(unsigned long max)
bool fast = is_prime_number(x);

if (slow != fast) {
pr_err("inconsistent result for is-prime(%lu): slow=%s, fast=%s!",
pr_err("inconsistent result for is-prime(%lu): slow=%s, fast=%s!\n",
x, slow ? "yes" : "no", fast ? "yes" : "no");
goto err;
}
Expand All @@ -282,14 +282,14 @@ static int selftest(unsigned long max)
continue;

if (next_prime_number(last) != x) {
pr_err("incorrect result for next-prime(%lu): expected %lu, got %lu",
pr_err("incorrect result for next-prime(%lu): expected %lu, got %lu\n",
last, x, next_prime_number(last));
goto err;
}
last = x;
}

pr_info("selftest(%lu) passed, last prime was %lu", x, last);
pr_info("%s(%lu) passed, last prime was %lu\n", __func__, x, last);
return 0;

err:
Expand Down

0 comments on commit 9ac1757

Please sign in to comment.