From: Peter Maydell <peter.maydell@linaro.org>
To: Alistair Francis <alistair23@gmail.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
qemu-arm <qemu-arm@nongnu.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Patch Tracking <patches@linaro.org>,
Sergey Fedorov <serge.fdrv@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] target-arm: Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps
Date: Sat, 20 Feb 2016 11:28:57 +0000 [thread overview]
Message-ID: <CAFEAcA8_oJZU_mHBbmSk0XvJPaevAri6A-UwBkMHCBh2op9h+A@mail.gmail.com> (raw)
In-Reply-To: <CAKmqyKNy79b8_k2wOO_v0DgXc3OCwhcHv7zVkcEPe_Fft6-Gpw@mail.gmail.com>
On 19 February 2016 at 19:38, Alistair Francis <alistair23@gmail.com> wrote:
> On Fri, Feb 19, 2016 at 6:39 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> +/* Check for traps to performance monitor registers, which are controlled
>> + * by MDCR_EL2.TPM for EL2 and MDCR_EL3.TPM for EL3.
>> + */
>> +static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri,
>> + bool isread)
>> +{
>> + int el = arm_current_el(env);
>> +
>> + if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM)
>> + && !arm_is_secure_below_el3(env)) {
>> + return CP_ACCESS_TRAP_EL2;
>> + }
>> + if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) {
>> + return CP_ACCESS_TRAP_EL3;
>> + }
>
> Hey Peter,
>
> Why not use else if?
I generally tend not to use else-if ladders if the thing
in the conditional returns unconditionally, just as a
personal style preference. "if () { X } else if () { Y } Z"
implies a possible control flow path of "take the if
branch so run X, then skip Y, and continue after to run Z",
and if X returns unconditionally that can't happen.
It also matches up with the usual approach of
if (something) {
early return;
}
main body of function;
which you wouldn't want to write as
if (something) {
early return;
} else {
main body;
}
thanks
-- PMM
next prev parent reply other threads:[~2016-02-20 11:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 14:39 [Qemu-devel] [PATCH v2 0/2] Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps Peter Maydell
2016-02-19 14:39 ` [Qemu-devel] [PATCH v2 1/2] target-arm: Fix handling of SDCR for 32-bit code Peter Maydell
2016-02-19 16:31 ` Sergey Fedorov
2016-02-19 16:38 ` Peter Maydell
2016-02-22 18:08 ` Alistair Francis
2016-02-19 14:39 ` [Qemu-devel] [PATCH v2 2/2] target-arm: Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps Peter Maydell
2016-02-19 16:42 ` Sergey Fedorov
2016-02-19 19:38 ` Alistair Francis
2016-02-20 11:28 ` Peter Maydell [this message]
2016-02-22 18:06 ` Alistair Francis
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=CAFEAcA8_oJZU_mHBbmSk0XvJPaevAri6A-UwBkMHCBh2op9h+A@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=alistair23@gmail.com \
--cc=edgar.iglesias@gmail.com \
--cc=patches@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=serge.fdrv@gmail.com \
/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).