On Fri 15 May 2015 03:39:10 AM CEST, Fam Zheng <f...@redhat.com> wrote:
> int64_t ret = bdrv_nb_sectors(bs); > > + ret = (int64_t)(ret * BDRV_SECTOR_SIZE) < 0 ? -EFBIG : ret; > return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE; Maybe in this case you're safe, but in general there's no guarantee that if there's an overflow the result will be negative. You can do something like this instead: ret = ret > INT64_MAX / BDRV_SECTOR_SIZE ? -EFBIG : ret; Of course this is only valid if BDRV_SECTOR_SIZE != 0 ;) Berto