From: Peter Maydell <peter.maydell@linaro.org>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [Qemu-devel] [PATCH v3 RESEND 3/3] nvram: at24c: use standard error reporting
Date: Sun, 20 May 2018 14:27:54 +0100 [thread overview]
Message-ID: <CAFEAcA9-gA2PYsiOLu3cGFtg1aeCs8n5z+pydsVDeFhzzy2Axg@mail.gmail.com> (raw)
In-Reply-To: <20180520070037.8593-4-wsa+renesas@sang-engineering.com>
On 20 May 2018 at 08:00, Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> Replace the ERR macro with error_report() because fprintf is deprecated.
> This also fixes the prefix printed out twice.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> hw/nvram/eeprom_at24c.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
> @@ -63,8 +61,7 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
> if (ee->blk && ee->changed) {
> int len = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
> if (len != ee->rsize) {
> - ERR(TYPE_AT24C_EE
> - " : failed to write backing file\n");
> + error_report("failed to write backing file");
> }
> DPRINTK("Wrote to backing file\n");
> }
> @@ -125,7 +122,7 @@ int at24c_eeprom_init(I2CSlave *i2c)
> EEPROMState *ee = AT24C_EE(i2c);
>
> if (!ee->rsize) {
> - ERR("rom-size not allowed to be 0\n");
> + error_report("rom-size not allowed to be 0");
> exit(1);
> }
Hi; if we're going to overhaul the error handling for this
device, I think we might as well do it properly, by moving
the code in this init function which can fail into a new
device realize method. The realize method takes an Error**
and can report failures that way rather than by causing
QEMU to exit.
> @@ -166,8 +162,7 @@ void at24c_eeprom_reset(DeviceState *state)
> int len = blk_pread(ee->blk, 0, ee->mem, ee->rsize);
>
> if (len != ee->rsize) {
> - ERR(TYPE_AT24C_EE
> - " : Failed initial sync with backing file\n");
> + error_report("Failed initial sync with backing file");
> }
> DPRINTK("Reset read backing file\n");
> }
Errors in reset and event methods are a bit more awkward;
error_report is an improvement in those cases.
thanks
-- PMM
prev parent reply other threads:[~2018-05-20 13:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-20 7:00 [Qemu-devel] [PATCH v3 RESEND 0/3] nvram: at24c: fix problems related to "rom-size" Wolfram Sang
2018-05-20 7:00 ` [Qemu-devel] [PATCH v3 RESEND 1/3] nvram: at24c: prevent segfault by checking "rom-size" Wolfram Sang
2018-05-20 7:00 ` [Qemu-devel] [PATCH v3 RESEND 2/3] nvram: at24c: use a sane default for "rom-size" Wolfram Sang
2018-05-20 7:00 ` [Qemu-devel] [PATCH v3 RESEND 3/3] nvram: at24c: use standard error reporting Wolfram Sang
2018-05-20 13:27 ` Peter Maydell [this message]
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=CAFEAcA9-gA2PYsiOLu3cGFtg1aeCs8n5z+pydsVDeFhzzy2Axg@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=f4bug@amsat.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=wsa+renesas@sang-engineering.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).