On 11/27/25 05:55, Honglei Huang wrote: > > > On 2025/11/26 20:08, Dmitry Osipenko wrote: >> On 11/26/25 05:02, Honglei Huang wrote: >>> Unify error checking style for virtio_gpu_create_mapping_iov() across >>> the >>> codebase to improve consistency and readability. >>> >>> virtio_gpu_create_mapping_iov() returns 0 on success and negative values >>> on error. The original code used inconsistent patterns for checking >>> errors: >>> - Some used 'if (ret != 0)' in virtio-gpu-virgl.c and virtio-gpu.c >>> - Some used 'CHECK(!ret, cmd)' in virtio-gpu-rutabaga.c >>> >>> For if-statement checks, change to 'if (ret < 0)' which is the preferred >>> QEMU coding convention for functions that return 0 on success and >>> negative >>> on error. This makes the return value convention immediately clear to >>> code >>> readers. >>> >>> For CHECK macro usage in virtio-gpu-rutabaga.c, keep the original >>> 'CHECK(!ret, cmd)' pattern as it is more concise and consistent with >>> other >>> error checks in the same file. >>> >>> Updated locations: >>> - hw/display/virtio-gpu-virgl.c: virgl_resource_attach_backing() >>> - hw/display/virtio-gpu-virgl.c: virgl_cmd_resource_create_blob() >>> - hw/display/virtio-gpu.c: virtio_gpu_resource_create_blob() >>> - hw/display/virtio-gpu.c: virtio_gpu_resource_attach_backing() >>> >>> Signed-off-by: Honglei Huang <[email protected]> >>> Reviewed-by: Markus Armbruster <[email protected]> >>> --- >>> hw/display/virtio-gpu-virgl.c | 4 ++-- >>> hw/display/virtio-gpu.c | 4 ++-- >>> 2 files changed, 4 insertions(+), 4 deletions(-) >>> >>> diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu- >>> virgl.c >>> index e60e1059df..6ebd9293e5 100644 >>> --- a/hw/display/virtio-gpu-virgl.c >>> +++ b/hw/display/virtio-gpu-virgl.c >>> @@ -557,7 +557,7 @@ static void >>> virgl_resource_attach_backing(VirtIOGPU *g, >>> ret = virtio_gpu_create_mapping_iov(g, att_rb.nr_entries, >>> sizeof(att_rb), >>> cmd, NULL, &res_iovs, >>> &res_niov); >>> - if (ret != 0) { >>> + if (ret < 0) { >>> cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; >>> return; >>> } >>> @@ -701,7 +701,7 @@ static void >>> virgl_cmd_resource_create_blob(VirtIOGPU *g, >>> ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, >>> sizeof(cblob), >>> cmd, &res->base.addrs, >>> &res->base.iov, &res- >>> >base.iov_cnt); >>> - if (ret != 0) { >>> + if (ret < 0) { >>> cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; >>> return; >>> } >>> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c >>> index 0a1a625b0e..1038c6a49f 100644 >>> --- a/hw/display/virtio-gpu.c >>> +++ b/hw/display/virtio-gpu.c >>> @@ -352,7 +352,7 @@ static void >>> virtio_gpu_resource_create_blob(VirtIOGPU *g, >>> ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, >>> sizeof(cblob), >>> cmd, &res->addrs, &res->iov, >>> &res->iov_cnt); >>> - if (ret != 0) { >>> + if (ret < 0) { >>> cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; >>> g_free(res); >>> return; >>> @@ -931,7 +931,7 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, >>> ret = virtio_gpu_create_mapping_iov(g, ab.nr_entries, >>> sizeof(ab), cmd, >>> &res->addrs, &res->iov, >>> &res->iov_cnt); >>> - if (ret != 0) { >>> + if (ret < 0) { >>> cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; >>> return; >>> } >> >> Reviewed-by: Dmitry Osipenko <[email protected]> >> > > Really thanks for the review and patience.
There is a last word from Alex here, though likely the current version will be good to him, Thanks for the contribution. -- Best regards, Dmitry
