[PATCH] um: virtio-pci: Use pointer from memcpy() call for assignment in virtio_pcidev_send_cmd()

From: Markus Elfring

Date: Fri Oct 31 2025 - 04:05:25 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 31 Oct 2025 08:58:22 +0100

A pointer was assigned to a variable. The same pointer was used for
the destination parameter of a memcpy() call.
This function is documented in the way that the same value is returned.
Thus convert two separate statements into a direct variable assignment for
the return value from a memory copy action.

The source code was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
arch/um/drivers/virtio_pcidev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/um/drivers/virtio_pcidev.c b/arch/um/drivers/virtio_pcidev.c
index f9b4b6f7582c..33f6889cce7b 100644
--- a/arch/um/drivers/virtio_pcidev.c
+++ b/arch/um/drivers/virtio_pcidev.c
@@ -125,8 +125,7 @@ static int virtio_pcidev_send_cmd(struct virtio_pcidev_device *dev,
out && out_size <= sizeof(buf->data);

buf_idx = virtio_pcidev_get_buf(dev, &posted);
- buf = &dev->bufs[buf_idx];
- memcpy(buf, cmd, cmd_size);
+ buf = memcpy(&dev->bufs[buf_idx], cmd, cmd_size);

if (posted && extra && extra_size > sizeof(buf) - cmd_size) {
dev->extra_ptrs[buf_idx] = kmemdup(extra, extra_size,
--
2.51.1