From: Joe Perches <joe@perches.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Zhu Lingshan <lingshan.zhu@intel.com>,
wanpengli@tencent.com, Like Xu <like.xu@linux.intel.com>,
eranian@google.com, weijiang.yang@intel.com,
Guo Ren <guoren@kernel.org>,
linux-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
kvmarm@lists.cs.columbia.edu, kan.liang@linux.intel.com,
ak@linux.intel.com, kvm@vger.kernel.org,
Marc Zyngier <maz@kernel.org>,
joro@8bytes.org, x86@kernel.org, linux-csky@vger.kernel.org,
wei.w.wang@intel.com, xen-devel@lists.xenproject.org,
liuxiangdong5@huawei.com, bp@alien8.de,
Paul Walmsley <paul.walmsley@sifive.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
linux-arm-kernel@lists.infradead.org, jmattson@google.com,
like.xu.linux@gmail.com, Nick Hu <nickhu@andestech.com>,
seanjc@google.com, linux-kernel@vger.kernel.org,
pbonzini@redhat.com, vkuznets@redhat.com
Subject: Re: [PATCH V7 01/18] perf/core: Use static_call to optimize perf_guest_info_callbacks
Date: Fri, 02 Jul 2021 09:56:51 -0700 [thread overview]
Message-ID: <7a2ef915bd08a1c0277b9633e20905c0ca62c568.camel@perches.com> (raw)
In-Reply-To: <20210702163836.GB94260@C02TD0UTHF1T.local>
On Fri, 2021-07-02 at 17:38 +0100, Mark Rutland wrote:
> On Fri, Jul 02, 2021 at 09:00:22AM -0700, Joe Perches wrote:
> > On Fri, 2021-07-02 at 13:22 +0200, Peter Zijlstra wrote:
> > > On Tue, Jun 22, 2021 at 05:42:49PM +0800, Zhu Lingshan wrote:
[]
> > > > + if (perf_guest_cbs && perf_guest_cbs->handle_intel_pt_intr)
> > > > + static_call_update(x86_guest_handle_intel_pt_intr,
> > > > + perf_guest_cbs->handle_intel_pt_intr);
> > > > +}
> > >
> > > Coding style wants { } on that last if().
> >
> > That's just your personal preference.
> >
> > The coding-style document doesn't require that.
> >
> > It just says single statement. It's not the number of
> > vertical lines or characters required for the statement.
> >
> > ----------------------------------
> >
> > Do not unnecessarily use braces where a single statement will do.
> >
> > .. code-block:: c
> >
> > if (condition)
> > action();
> >
> > and
> >
> > .. code-block:: none
> >
> > if (condition)
> > do_this();
> > else
> > do_that();
> >
> > This does not apply if only one branch of a conditional statement is a single
> > statement; in the latter case use braces in both branches:
>
> Immediately after this, we say:
>
> > Also, use braces when a loop contains more than a single simple statement:
> >
> > .. code-block:: c
> >
> > while (condition) {
> > if (test)
> > do_something();
> > }
> >
>
> ... and while that says "a loop", the principle is obviously supposed to
> apply to conditionals too; structurally they're no different. We should
> just fix the documentation to say "a loop or conditional", or something
> to that effect.
<shrug> Maybe.
I think there are _way_ too many existing obvious uses where the
statement that follows a conditional is multi-line.
if (foo)
printk(fmt,
args...);
where the braces wouldn't add anything other than more vertical space.
I don't much care one way or another other than Peter's somewhat ambiguous
use of the phrase "coding style".
checkpatch doesn't emit a message either way.
-----------------------------------------
$ cat t_multiline.c
// SPDX-License-Identifier: GPL-2.0-only
void foo(void)
{
if (foo) {
pr_info(fmt,
args);
}
if (foo)
pr_info(fmt,
args);
if (foo)
pr_info(fmt, args);
}
$ ./scripts/checkpatch.pl -f --strict t_multiline.c
total: 0 errors, 0 warnings, 0 checks, 16 lines checked
t_multiline.c has no obvious style problems and is ready for submission.
-----------------------------------------
cheers, Joe
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-07-02 16:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210622094306.8336-1-lingshan.zhu@intel.com>
2021-06-22 9:42 ` [PATCH V7 01/18] perf/core: Use static_call to optimize perf_guest_info_callbacks Zhu Lingshan
2021-07-02 11:22 ` Peter Zijlstra
2021-07-02 16:00 ` Joe Perches
2021-07-02 16:19 ` Peter Zijlstra
2021-07-02 16:42 ` Joe Perches
2021-07-02 16:38 ` Mark Rutland
2021-07-02 16:56 ` Joe Perches [this message]
2021-07-08 8:53 ` Zhu Lingshan
[not found] <20210622093823.8215-1-lingshan.zhu@intel.com>
2021-06-22 9:38 ` Zhu Lingshan
2021-06-22 17:31 ` Boris Ostrovsky
2021-06-23 9:06 ` Zhu, Lingshan
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=7a2ef915bd08a1c0277b9633e20905c0ca62c568.camel@perches.com \
--to=joe@perches.com \
--cc=ak@linux.intel.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=guoren@kernel.org \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kan.liang@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=like.xu.linux@gmail.com \
--cc=like.xu@linux.intel.com \
--cc=lingshan.zhu@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=liuxiangdong5@huawei.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=nickhu@andestech.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=wei.w.wang@intel.com \
--cc=weijiang.yang@intel.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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).