From: Philippe Mathieu-Daudé Date: Mon, 11 Nov 2024 17:03:32 +0000 (+0100) Subject: block: Improve blk_get_attached_dev_id() docstring X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=84d388c22b8e34981539fd3c69f84099f1824f1f;p=qemu.git block: Improve blk_get_attached_dev_id() docstring Expose the method docstring in the header, and mention returned value must be free'd by caller. Reported-by: Fabiano Rosas Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20241111170333.43833-2-philmd@linaro.org> Signed-off-by: Kevin Wolf --- diff --git a/block/block-backend.c b/block/block-backend.c index c93a7525ad..789fc6d4ea 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1019,6 +1019,10 @@ DeviceState *blk_get_attached_dev(BlockBackend *blk) return blk->dev; } +/* + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_id) { DeviceState *dev = blk->dev; @@ -1033,15 +1037,15 @@ static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_id) return object_get_canonical_path(OBJECT(dev)) ?: g_strdup(""); } -/* - * Return the qdev ID, or if no ID is assigned the QOM path, of the block - * device attached to the BlockBackend. - */ char *blk_get_attached_dev_id(BlockBackend *blk) { return blk_get_attached_dev_id_or_path(blk, true); } +/* + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ static char *blk_get_attached_dev_path(BlockBackend *blk) { return blk_get_attached_dev_id_or_path(blk, false); diff --git a/include/system/block-backend-io.h b/include/system/block-backend-io.h index d174275a5c..ba8dfcc7d0 100644 --- a/include/system/block-backend-io.h +++ b/include/system/block-backend-io.h @@ -32,6 +32,13 @@ void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow); void blk_set_disable_request_queuing(BlockBackend *blk, bool disable); bool blk_iostatus_is_enabled(const BlockBackend *blk); +/* + * Return the qdev ID, or if no ID is assigned the QOM path, + * of the block device attached to the BlockBackend. + * + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ char *blk_get_attached_dev_id(BlockBackend *blk); BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,