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

From: Logan Gunthorpe
Date: Mon Nov 27 2017 - 17:57:04 EST




On 27/11/17 01:49 PM, Julia Lawall wrote:
Perhaps if there is a possible flow from one print to another within a
single function and in both cases the format string is at least say 25
characters (completely random value), then it is pretty likely that a
newline is intended.

This is on the edge of what I think could be done with checkpatch. I did a quick look through some of the cases I've noticed and haven't found any that this wouldn't pass. I'm not sure how you'd pick an appropriate threshold though. I do think it's quite clever, though.

Alternatively, if the first format string doesn't end in a space and the
second one doesn't begin with a space, then a newline is also likely
intended.

This makes more sense to me but I don't expect it to be 100% accurate either. See, for example, drivers/char/dtlk.c:640 which has no space in either printk. You could maybe expand the rule to include ':' and '(' as the last character.

Logan