Fabiano Rosas <[email protected]> writes:

> Using newlines in the g_test_message is fine. It automatically adds
> the '#' required by the TAP protocol to the start of each line.
>
> Relax the regex for this function, but still forbid a trailing newline
> because it's added automatically and usually not what the user wants.
>
> Signed-off-by: Fabiano Rosas <[email protected]>
> ---
>  scripts/checkpatch.pl | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 03f35e75012..fd4534b3a1e 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3303,13 +3303,20 @@ sub process {
>                                        info_vreport|
>                                        error_report|
>                                        warn_report|
> -                                      info_report|
> -                                      g_test_message}x;
> +                                      info_report}x;
>  
>               if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
>                       ERROR("Error messages should not contain newlines\n" . 
> $herecurr);
>               }
>  
> +             # No newlines at the end
> +             my $trail_newline_error_funcs = qr{g_test_message}x;
> +
> +             if ($rawline =~ 
> /\b(?:$trail_newline_error_funcs)\(.*\".*\\n\"/) {

Unlike the regexp above, this one doesn't accept spaces between the
function name and the parenthesis.  We generally don't have spaces
there, but why rely on that?

> +                 ERROR("Error messages should not contain trailing " .
> +                       "newlines\n" . $herecurr);
> +             }
> +
>               # Continue checking for error messages that contains newlines.
>               # This check handles cases where string literals are spread
>               # over multiple lines.

With the spaces accepted
Reviewed-by: Markus Armbruster <[email protected]>


Reply via email to