}
/* Check for a matching GPT disk/partition guid */
do {
- if (!memcmp(&boot_part->gpt.part_guid, gpt_guid, sizeof(*gpt_guid)))
+ if (!memcmp(&boot_part->gpt.part_guid, gpt_guid, sizeof *gpt_guid))
goto ok;
} while (!pi_next(boot_part));
}
console_ansi_raw();
- memset(&fdat, 0, sizeof(fdat));
- memset(&hdat, 0, sizeof(hdat));
- memset(&sdat, 0, sizeof(sdat));
+ memset(&fdat, 0, sizeof fdat);
+ memset(&hdat, 0, sizeof hdat);
+ memset(&sdat, 0, sizeof sdat);
opt_set_defs();
if (opt_parse_args(argc, argv))
*/
if (opt.file)
- memcpy(data + ndata++, &fdat, sizeof(fdat));
+ memcpy(data + ndata++, &fdat, sizeof fdat);
if (opt.maps)
- memcpy(data + ndata++, &sdat, sizeof(sdat));
+ memcpy(data + ndata++, &sdat, sizeof sdat);
if (opt.hand)
- memcpy(data + ndata++, &hdat, sizeof(hdat));
+ memcpy(data + ndata++, &hdat, sizeof hdat);
#ifdef DEBUG
dprintf("iter->di dsk, bps: %X, %u\niter->di lbacnt, C*H*S: %"PRIu64", %u\n"
if (!(opt.file && opt.grub))
return 0;
- if (data->size < sizeof(struct grub_stage2_patch_area)) {
+ if (data->size < sizeof *stage2) {
error("The file specified by grub=<loader> is too small to be stage2 of GRUB Legacy.");
goto bail;
}
* the default config filename "/boot/grub/menu.lst".
*/
if (opt.grubcfg) {
- if (strlen(opt.grubcfg) > sizeof(stage2->config_file) - 1) {
+ if (strlen(opt.grubcfg) >= sizeof stage2->config_file) {
error("The config filename length can't exceed 88 characters.");
goto bail;
}
if (!(opt.sect && opt.cmldr))
return 0;
- memcpy((char *)data->data + 3, cmldr_signature, sizeof(cmldr_signature));
+ memcpy((char *)data->data + 3, cmldr_signature, sizeof cmldr_signature);
return 0;
}
void opt_set_defs(void)
{
- memset(&opt, 0, sizeof(opt));
+ memset(&opt, 0, sizeof opt);
opt.sect = true; /* by def. load sector */
opt.maps = true; /* by def. map sector */
opt.hand = true; /* by def. prepare handover */
const struct disk_info *di, int flags
)
{
- memcpy(&iter->di, di, sizeof(struct disk_info));
+ memcpy(&iter->di, di, sizeof *di);
iter->flags = flags;
iter->index0 = -1;
iter->length = di->lbacnt;
if (pi_ctor(iter, di, flags))
return -1;
- if (!(iter->data = malloc(sizeof(struct disk_dos_mbr)))) {
+ if (!(iter->data = malloc(sizeof *mbr))) {
critm();
goto bail;
}
- memcpy(iter->data, mbr, sizeof(struct disk_dos_mbr));
+ memcpy(iter->data, mbr, sizeof *mbr);
iter->dos.bebr_index0 = -1;
iter->dos.disk_sig = mbr->disk_sig;
iter->gpt.ufirst = gpth->lba_first_usable;
iter->gpt.ulast = gpth->lba_last_usable;
- memcpy(&iter->gpt.disk_guid, &gpth->disk_guid, sizeof(struct guid));
- memcpy(&iter->gpt.part_guid, &gpth->disk_guid, sizeof(struct guid));
+ memcpy(&iter->gpt.disk_guid, &gpth->disk_guid, sizeof gpth->disk_guid);
+ memcpy(&iter->gpt.part_guid, &gpth->disk_guid, sizeof gpth->disk_guid);
iter->type = typegpt;
return 0;
static struct part_iter *pi_alloc(void)
{
struct part_iter *iter;
- if (!(iter = malloc(sizeof(struct part_iter))))
+ if (!(iter = malloc(sizeof *iter)))
critm();
else
- memset(iter, 0, sizeof(struct part_iter));
+ memset(iter, 0, sizeof *iter);
return iter;
}
}
if (gpth && gpth->rev.uint32 == 0x00010000 &&
- !memcmp(gpth->sig, disk_gpt_sig_magic, sizeof(disk_gpt_sig_magic))) {
+ !memcmp(gpth->sig, disk_gpt_sig_magic, sizeof gpth->sig)) {
/* looks like GPT v1.0 */
uint64_t gpt_loff; /* offset to GPT partition list in sectors */
uint64_t gpt_lsiz; /* size of GPT partition list in bytes */
!sane(gpth->lba_last_usable, gpt_lcnt) ||
gpth->lba_last_usable + gpt_lcnt >= gpth->lba_alt ||
gpth->lba_alt >= di->lbacnt ||
- gpth->part_size < sizeof(struct disk_gpt_part_entry))) {
+ gpth->part_size < sizeof *gptl)) {
error("Invalid GPT header's values.");
goto bail;
}