From: Markus Armbruster Date: Wed, 19 Nov 2025 13:08:52 +0000 (+0100) Subject: hw/nvram/xlnx-bbram: More idiomatic and simpler error reporting X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51cd475682ce3e3b7ce386d85bc81f3b4a30fd36;p=thirdparty%2Fqemu.git 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 Message-ID: <20251119130855.105479-3-armbru@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Luc Michel Reviewed-by: Zhao Liu --- diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c index 60ede7e40f..edfb592a5e 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 */