Skip to contentSkip to conversation

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

PATCH New Markus Elfring 1 participant 1 message Oct 31, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Markus Elfring <[email protected]>
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.

---
 arch/um/drivers/virtio_pcidev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/um/drivers/virtio_pcidev.c +1 -2
index f9b4b6f7582c..33f6889cce7b 100644
@@ -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,
Signature · 1 line
2.51.1