Re: [PATCH 2/2][RFC] mmc: cast unsigned int to typeof(sector_t) to avoid unexpected error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

> card->csd.capacity is defined as "unsigned int",
> and, sector_t is defined as "u64" or "unsigned long" (depends on CONFIG_LBDAF)
> sector_t data might have strange data if first bit of unsigned int
> was 1. this patch cast it to typeof(sector_t)
> 
> ex) if sector_t was u64
> 
>         unsigned int data;
>         sector_t sector;
> 
>         data = 0x80000000;
>         sector = (data << 8); // 0xffffff8000000000
>         sector = (((typeof(sector_t))data) << 8); // 0x8000000000

Sorry, I noticed this explain (= number of 0) was wrong
Maybe it should be

         data = 0x800000;
         sector = (data << 8); // 0xffffffff80000000
         sector = (((typeof(sector_t))data) << 8); // 0x80000000

or

         data = 0x80000000;
         sector = (data << 8); // 0x0
         sector = (((typeof(sector_t))data) << 8); // 0x8000000000
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux