header->alternative_lba = cpu_to_le64(cxt->total_sectors - 1ULL);
header->partition_entry_lba = cpu_to_le64(2ULL);
} else { /* backup */
- uint64_t esz = le32_to_cpu(header->npartition_entries) * sizeof(struct gpt_entry);
+ uint64_t esz = (uint64_t) le32_to_cpu(header->npartition_entries)
+ * sizeof(struct gpt_entry);
uint64_t esects = (esz + cxt->sector_size - 1) / cxt->sector_size;
header->alternative_lba = cpu_to_le64(GPT_PRIMARY_PARTITION_TABLE_LBA);
if (res->my_lba == GPT_PRIMARY_PARTITION_TABLE_LBA)
res->partition_entry_lba = cpu_to_le64(2ULL);
else {
- uint64_t esz = le32_to_cpu(src->npartition_entries) * sizeof(struct gpt_entry);
+ uint64_t esz = (uint64_t) le32_to_cpu(src->npartition_entries) * sizeof(struct gpt_entry);
uint64_t esects = (esz + cxt->sector_size - 1) / cxt->sector_size;
res->partition_entry_lba = cpu_to_le64(cxt->total_sectors - 1ULL - esects);
assert(cxt);
assert(header);
- sz = le32_to_cpu(header->npartition_entries) *
+ sz = (ssize_t) le32_to_cpu(header->npartition_entries) *
le32_to_cpu(header->sizeof_partition_entry);
ret = calloc(1, sz);
if (!ret)
return NULL;
- offset = le64_to_cpu(header->partition_entry_lba) *
+ offset = (off_t) le64_to_cpu(header->partition_entry_lba) *
cxt->sector_size;
if (offset != lseek(cxt->dev_fd, offset, SEEK_SET))
{
size_t arysz = 0;
- arysz = le32_to_cpu(header->npartition_entries) *
+ arysz = (size_t) le32_to_cpu(header->npartition_entries) *
le32_to_cpu(header->sizeof_partition_entry);
return count_crc32((unsigned char *) ents, arysz, 0, 0);
case 2:
*name = _("GPT Entries");
gpt = self_label(cxt);
- *offset = le64_to_cpu(gpt->pheader->partition_entry_lba) * cxt->sector_size;
- *size = le32_to_cpu(gpt->pheader->npartition_entries) *
- le32_to_cpu(gpt->pheader->sizeof_partition_entry);
+ *offset = (uint64_t) le64_to_cpu(gpt->pheader->partition_entry_lba) *
+ cxt->sector_size;
+ *size = (size_t) le32_to_cpu(gpt->pheader->npartition_entries) *
+ le32_to_cpu(gpt->pheader->sizeof_partition_entry);
break;
default:
return 1; /* no more chunks */
static int gpt_write_partitions(struct fdisk_context *cxt,
struct gpt_header *header, struct gpt_entry *ents)
{
- off_t offset = le64_to_cpu(header->partition_entry_lba) * cxt->sector_size;
+ off_t offset = (off_t) le64_to_cpu(header->partition_entry_lba) * cxt->sector_size;
uint32_t nparts = le32_to_cpu(header->npartition_entries);
uint32_t totwrite = nparts * le32_to_cpu(header->sizeof_partition_entry);
ssize_t rc;
static int gpt_create_disklabel(struct fdisk_context *cxt)
{
int rc = 0;
- ssize_t esz = 0;
+ size_t esz = 0;
char str[37];
struct fdisk_gpt_label *gpt;
if (rc < 0)
goto done;
- esz = le32_to_cpu(gpt->pheader->npartition_entries) *
+ esz = (size_t) le32_to_cpu(gpt->pheader->npartition_entries) *
le32_to_cpu(gpt->pheader->sizeof_partition_entry);
gpt->ents = calloc(1, esz);
if (!gpt->ents) {