Re: [PATCH] checkpatch: check for missing \n at the end of logging message

From: Christophe JAILLET
Date: Thu Apr 09 2020 - 13:34:22 EST


Le 09/04/2020 Ã 17:29, Joe Perches a ÃcritÂ:
On Thu, 2020-04-09 at 09:24 +0200, Christophe JAILLET wrote:
I think that, at least printk(), WARN() and co, and panic() should also
be handled the same way.
Maybe.

A few files (5 according to my grep) also have something like:
#define pr_fmt(fmt) "bcache: %s()" fmt "\n", __func__
and then sometimes a mix of pr_xxx() with either trailing \n or not.
Didn't know about those.

Maybe those should be handled manually to be consistent and avoid a "\n"
in pr_fmt which is not widely used in other files
More likely the pr_fmt should have the \n removed and added
to the uses.
Yes agreed.
$ git grep -P 'define\s+pr_fmt.*\\n'
drivers/clocksource/timer-davinci.c:#define pr_fmt(fmt) "%s: " fmt "\n", __func__
https://marc.info/?l=linux-kernel&m=158642435216181&w=4 (which has been acked)

lib/math/prime_numbers.c:#define pr_fmt(fmt) "prime numbers: " fmt "\n"
lib/test_hash.c:#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt "\n"
Patches proposed.
lib/percpu-refcount.c:#define pr_fmt(fmt) "%s: " fmt "\n", __func__
In this file, there are some WARN_ON.
Are these log functions also influenced by pr_fmt?
drivers/md/bcache/bcache.h:#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
drivers/md/bcache/bset.c:#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
tools/usb/usbip/libsrc/usbip_common.h:#define pr_fmt(fmt) "%s: %s: " fmt "\n", PROGNAME

Tricky because all files that include it have to be checked.
I won't touch these ones.

CJ