Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkpatch: add warning for pr_* and dev_* macros without a trailing …
…newline Add a new check in scripts/checkpatch.pl to detect usage of pr_(level) and dev_(level) macros (for both C and Rust) when the string literal does not end with '\n'. Missing trailing newlines can lead to incomplete log lines that do not appear properly in dmesg or in console output. To show an example of this working after applying the patch we can run the script on the commit that likely motivated this need/issue: ./scripts/checkpatch.pl --strict -g "f431c5c581fa1" Also, the patch is able to handle correctly if there is a printing call without a newline which then has a newline printed via pr_cont for both Rust and C alike. If there is no newline printed and the patch ends or there is another pr_* call before a newline with pr_cont is printed it will show a warning. Not implemented for dev_cont because it is not clear to me if that is used at all. One false warning that will be generated due to this change is in case we have a patch that modifies a `pr_* call without a newline` which has a pr_cont with a newline following it. In this case there will be a warning but because the patch does not include the following pr_cont it will warn there is nothing creating a newline. I have modified the warning to be softer due to this known problem. I have tested with comments, whitespace, differen orders of pr_* calls and pr_cont and the only case that I suspect to be a problem is the one outlined above. Suggested-by: Miguel Ojeda <ojeda@kernel.org> Closes: Rust-for-Linux#1140 Signed-off-by: Alban Kurti <kurti@invicto.ai>
- Loading branch information