|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/5] hw/nvram/xlnx-bbram: More idiomatic and simpler error reporting
bbram_bdrv_error() interpolates a "detail" string into a template with
error_setg_errno(), then reports the result with error_report().
Produces error messages with an unwanted '.':
BLK-NAME: BBRAM backstore DETAIL failed.: STERROR
Replace both calls of bbram_bdrv_error() by straightforward
error_report(), and drop the function. This is less code, easier to
read, and the error message is more greppable.
Also delete the unwanted '.'.
Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
---
hw/nvram/xlnx-bbram.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
index 22aefbc240..fe289bad9d 100644
--- a/hw/nvram/xlnx-bbram.c
+++ b/hw/nvram/xlnx-bbram.c
@@ -88,18 +88,6 @@ static bool bbram_pgm_enabled(XlnxBBRam *s)
return ARRAY_FIELD_EX32(s->regs, BBRAM_STATUS, PGM_MODE) != 0;
}
-static void bbram_bdrv_error(XlnxBBRam *s, int rc, gchar *detail)
-{
- Error *errp = NULL;
-
- error_setg_errno(&errp, -rc, "%s: BBRAM backstore %s failed.",
- blk_name(s->blk), detail);
- error_report("%s", error_get_pretty(errp));
- error_free(errp);
-
- g_free(detail);
-}
-
static void bbram_bdrv_read(XlnxBBRam *s, Error **errp)
{
uint32_t *ram = &s->regs[R_BBRAM_0];
@@ -162,7 +150,8 @@ static void bbram_bdrv_sync(XlnxBBRam *s, uint64_t hwaddr)
offset = hwaddr - A_BBRAM_0;
rc = blk_pwrite(s->blk, offset, 4, &le32, 0);
if (rc < 0) {
- bbram_bdrv_error(s, rc, g_strdup_printf("write to offset %u", offset));
+ error_report("%s: BBRAM backstore write to offset %u failed: %s",
+ blk_name(s->blk), offset, strerror(-rc));
}
}
@@ -178,7 +167,8 @@ static void bbram_bdrv_zero(XlnxBBRam *s)
rc = blk_make_zero(s->blk, 0);
if (rc < 0) {
- bbram_bdrv_error(s, rc, g_strdup("zeroizing"));
+ error_report("%s: BBRAM backstore zeroizing failed: %s",
+ blk_name(s->blk), strerror(-rc));
}
/* Restore bbram8 if it is non-zero */
--
2.49.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |