Skip to contentSkip to conversation

mmc: silence a shift wrapping warning

PATCH Applied Dan Carpenter 2 participants 2 messages Oct 23, 2014 – Oct 27, 2014

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

PATCH 1/1 mmc: silence a shift wrapping warning

Presumably ->slotno is normally fairly small and the shift doesn't wrap but static checkers will complain about it.

drivers/mmc/core/sdio_bus.c +1 -1
index 6da97b1..9a98cc7 100644
@@ -295,7 +295,7 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
 static void sdio_acpi_set_handle(struct sdio_func *func)
 {
 	struct mmc_host *host = func->card->host;
-	u64 addr = (host->slotno << 16) | func->num;
+	u64 addr = ((u64)host->slotno << 16) | func->num;
 
 	acpi_preset_companion(&func->dev, ACPI_COMPANION(host->parent), addr);
 }
Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

Presumably ->slotno is normally fairly small and the shift doesn't wrap but static checkers will complain about it.

Thanks! Applied for next.

Kind regards
Uffe

Quoted 14 lines
drivers/mmc/core/sdio_bus.c +1 -1
index 6da97b1..9a98cc7 100644
@@ -295,7 +295,7 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
 static void sdio_acpi_set_handle(struct sdio_func *func)
 {
        struct mmc_host *host = func->card->host;
-       u64 addr = (host->slotno << 16) | func->num;
+       u64 addr = ((u64)host->slotno << 16) | func->num;
 
        acpi_preset_companion(&func->dev, ACPI_COMPANION(host->parent), addr);
 }