From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC] checkpatch: do not warn for multiline parenthesized returned value
Date: Fri, 21 Jun 2019 08:47:35 -0500 [thread overview]
Message-ID: <e76b21df-8e24-e2d8-2504-5dd13ade2192@redhat.com> (raw)
In-Reply-To: <1561116534-21814-1-git-send-email-pbonzini@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1319 bytes --]
On 6/21/19 6:28 AM, Paolo Bonzini wrote:
> While indeed we do not want to have
>
> return (a);
>
> it is less clear that this applies to
>
> return (a &&
> b);
>
> Some editors indent more nicely if you have parentheses, and some people's
> eyes may appreciate that as well.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> scripts/checkpatch.pl | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
I'm certainly in favor of this (as I've been known to use this style).
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index c2aaf42..2f81371 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2296,7 +2296,8 @@ sub process {
> $value =~ s/\([^\(\)]*\)/1/) {
> }
> #print "value<$value>\n";
> - if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
> + if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/ &&
> + $line =~ /;$/) {
So the diagnosis now checks for a trailing ';' as its witness of whether
this is a one-liner return statement, leaving multi-liners undiagnosed.
Easy enough to understand.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-06-21 13:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 11:28 [Qemu-devel] [PATCH RFC] checkpatch: do not warn for multiline parenthesized returned value Paolo Bonzini
2019-06-21 13:47 ` Eric Blake [this message]
2019-06-24 9:00 ` Markus Armbruster
2019-06-25 15:12 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e76b21df-8e24-e2d8-2504-5dd13ade2192@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).