Re: [PATCH v2] checkpatch: Add a warning for log messages that don't end in a new line

From: Joe Perches
Date: Sun Nov 26 2017 - 01:01:45 EST


On Sun, 2017-11-26 at 06:51 +0100, Julia Lawall wrote:
>
> On Sat, 25 Nov 2017, Logan Gunthorpe wrote:
>
> > Check for lines with a log function using a relatively strict regular
> > expression catching only printk, dev_* and pr_* functions. Once
> > one is found, accumulate further lines for any functions that
> > are split over multiple lines.
>
> I don't understand at all the second sentence. Are you staying with the
> same call, or moving on to other calls? Also, it would be the call that
> is split over multiple lines, not the function split over multiple lines.
>
> I think this would have been much easier with Cocccinelle where the code
> is parsed and the control-flow graph is available to see whether there is
> a pr_cont afterwards. But if it works, then it is surely good enough.

It doesn't really work.

Many of the messages aren't missing newlines.

I only looked a the first few dozen instances, but many of
them aren't really missing newlines, but are now missing a
KERN_CONT annotation.

This is because Linus changed how printk worked awhile
ago in

commit 4bcc595ccd80decb4245096e3d1258989c50ed41
Author: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Date: Sat Oct 8 20:32:40 2016 -0700

printk: reinstate KERN_CONT for printing continuation lines

Most of that commit message is BS, but the net effect is
that now printks must have a KERN_<LEVEL> marker or a
newline is inserted before the format.

Also, this patch logic will be very confused by patch
blocks and not files.