Skip to contentSkip to conversation

ALSA: sc6000: Fix incorrect sizeof operator

PATCH In review Colin King 2 participants 2 messages Jul 20, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 ALSA: sc6000: Fix incorrect sizeof operator

From: Colin Ian King <[email protected]>

Static analysis is warning that the sizeof being used is should be of *vport and not vport. Although these are the same size it is not a portable assumption to assume this is true for all cases. Fix this by using sizeof(*vport).

Addresses-Coverity: ("Sizeof not portable")

Fixes 111601ff76e9 ("ALSA: sc6000: Allocate resources with device-managed APIs")
---
 sound/isa/sc6000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/isa/sc6000.c +1 -1
index 6236c4fa766a..44c05b55fc15 100644
@@ -552,7 +552,7 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
 
 
 	err = snd_devm_card_new(devptr, index[dev], id[dev], THIS_MODULE,
-				sizeof(vport), &card);
+				sizeof(*vport), &card);
 	if (err < 0)
 		return err;
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 11 lines · Colin King

From: Colin Ian King <[email protected]>

Static analysis is warning that the sizeof being used is should be of *vport and not vport. Although these are the same size it is not a portable assumption to assume this is true for all cases. Fix this by using sizeof(*vport).

Addresses-Coverity: ("Sizeof not portable")

Fixes 111601ff76e9 ("ALSA: sc6000: Allocate resources with device-managed APIs")

Thanks. I have another patch to drop this allocation (it's just a pointer, so no need for kmalloc, really), but since your patch is correct, I'll rebase on yours.

Takashi