Skip to contentSkip to conversation

um: virt-pci: Fix the application of sizeof to pointer

PATCH In review Yang Li 2 participants 2 messages Sep 3, 2021 User-mode Linux (UML)

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 um: virt-pci: Fix the application of sizeof to pointer

sizeof() when applied to a pointer typed expression gives the size of the pointer.

Clean up coccicheck warning:
./arch/um/drivers/virt-pci.c:192:20-26: ERROR: application of sizeof to pointer

---
 arch/um/drivers/virt-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/virt-pci.c +1 -1
index c080666..156af2f 100644
@@ -189,7 +189,7 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
 	buf = get_cpu_var(um_pci_msg_bufs);
 	data = buf->data;
 
-	memset(data, 0xff, sizeof(data));
+	memset(data, 0xff, sizeof(*data));
 
 	switch (size) {
 	case 1:
Signature · 1 line
1.8.3.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

arch/um/drivers/virt-pci.c static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset, · line 192

Quoted 10 lines · Yang Li

sizeof() when applied to a pointer typed expression gives the size of the pointer.

Clean up coccicheck warning:
./arch/um/drivers/virt-pci.c:192:20-26: ERROR: application of sizeof to pointer

arch/um/drivers/virt-pci.c +1 -1
-	memset(data, 0xff, sizeof(data));
+	memset(data, 0xff, sizeof(*data));

Oops. I guess I only tested on 64-bit where this is the same, and in fact on 32-bit it also wouldn't matter since you can't even do 64-bit reads there :)

A Fixes: tag would be nice, but otherwise

johannes

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um