From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
Qemu-block <qemu-block@nongnu.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v3 11/11] hw/sd/sdcard: Simplify realize() a bit
Date: Mon, 15 Jun 2020 15:24:46 +0100 [thread overview]
Message-ID: <CAFEAcA_K1gkMwpeXP2DQGTfiQZOGc9O94dLf84oJJJMVpTc-uQ@mail.gmail.com> (raw)
In-Reply-To: <20200605102230.21493-12-philmd@redhat.com>
On Fri, 5 Jun 2020 at 11:28, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> We don't need to check if sd->blk is set twice.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/sd/sd.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index a1b25ed36f..060ca9d993 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -2123,12 +2123,12 @@ static void sd_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> - if (sd->blk && blk_is_read_only(sd->blk)) {
> - error_setg(errp, "Cannot use read-only drive as SD card");
> - return;
> - }
> -
> if (sd->blk) {
> + if (blk_is_read_only(sd->blk)) {
> + error_setg(errp, "Cannot use read-only drive as SD card");
> + return;
> + }
> +
> ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
> BLK_PERM_ALL, errp);
> if (ret < 0) {
Originally written with the pattern of "check all the error cases
first; then do actual work". But if you prefer this way around
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
next prev parent reply other threads:[~2020-06-15 14:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 10:22 [PATCH v3 00/11] hw/sd/sdcard: Fix CVE-2020-13253 & cleanups Philippe Mathieu-Daudé
2020-06-05 10:22 ` [PATCH v3 01/11] MAINTAINERS: Cc qemu-block mailing list Philippe Mathieu-Daudé
2020-06-05 10:22 ` [PATCH v3 02/11] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Philippe Mathieu-Daudé
2020-06-15 13:30 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 03/11] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Philippe Mathieu-Daudé
2020-06-15 14:06 ` Peter Maydell
2020-07-13 16:36 ` Philippe Mathieu-Daudé
2020-07-13 16:49 ` Philippe Mathieu-Daudé
2020-06-05 10:22 ` [PATCH v3 04/11] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Philippe Mathieu-Daudé
2020-06-15 13:28 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 05/11] hw/sd/sdcard: Update the SDState documentation Philippe Mathieu-Daudé
2020-06-15 14:07 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 06/11] hw/sd/sdcard: Simplify cmd_valid_while_locked() Philippe Mathieu-Daudé
2020-06-15 14:08 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 07/11] hw/sd/sdcard: Constify sd_crc*()'s message argument Philippe Mathieu-Daudé
2020-06-05 10:22 ` [PATCH v3 08/11] hw/sd/sdcard: Make iolen unsigned Philippe Mathieu-Daudé
2020-06-15 14:13 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 09/11] hw/sd/sdcard: Correctly display the command name in trace events Philippe Mathieu-Daudé
2020-06-15 14:20 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 10/11] hw/sd/sdcard: Display offset in read/write_data() " Philippe Mathieu-Daudé
2020-06-15 14:21 ` Peter Maydell
2020-06-05 10:22 ` [PATCH v3 11/11] hw/sd/sdcard: Simplify realize() a bit Philippe Mathieu-Daudé
2020-06-15 14:24 ` Peter Maydell [this message]
2020-06-08 17:48 ` [PATCH v3 00/11] hw/sd/sdcard: Fix CVE-2020-13253 & cleanups Philippe Mathieu-Daudé
2020-07-06 16:31 ` Alistair Francis
2020-07-06 18:01 ` Philippe Mathieu-Daudé
2020-06-15 7:33 ` Philippe Mathieu-Daudé
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=CAFEAcA_K1gkMwpeXP2DQGTfiQZOGc9O94dLf84oJJJMVpTc-uQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=f4bug@amsat.org \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--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).