com32/chain: sizeof style change (trivial)
authorMichal Soltys <soltys@ziu.info>
Thu, 14 Feb 2013 15:51:47 +0000 (16:51 +0100)
committerMichal Soltys <soltys@ziu.info>
Thu, 14 Feb 2013 15:54:03 +0000 (16:54 +0100)
Signed-off-by: Michal Soltys <soltys@ziu.info>
com32/chain/chain.c
com32/chain/mangle.c
com32/chain/options.c
com32/chain/partiter.c

index bcc6468..d59ab87 100644 (file)
@@ -111,7 +111,7 @@ static int find_by_guid(const struct guid *gpt_guid,
        }
        /* 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));
     }
@@ -490,9 +490,9 @@ int main(int argc, char *argv[])
 
     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))
@@ -612,11 +612,11 @@ int main(int argc, char *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"
index 0c7319b..ffdaab8 100644 (file)
@@ -161,7 +161,7 @@ int manglef_grub(const struct part_iter *iter, struct data_area *data)
     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;
     }
@@ -211,7 +211,7 @@ int manglef_grub(const struct part_iter *iter, struct data_area *data)
      * 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;
        }
@@ -421,7 +421,7 @@ int mangles_cmldr(struct data_area *data)
     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;
 }
 
index 38881e7..4e722a0 100644 (file)
@@ -167,7 +167,7 @@ static void usage(void)
 
 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 */
index ced3a45..1eb5350 100644 (file)
@@ -84,7 +84,7 @@ static int pi_ctor(struct part_iter *iter,
        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;
@@ -102,12 +102,12 @@ static int pi_dos_ctor(struct part_iter *iter,
     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;
@@ -144,8 +144,8 @@ static int pi_gpt_ctor(struct part_iter *iter,
     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;
@@ -529,10 +529,10 @@ static int pi_gpt_next(struct part_iter *iter)
 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;
 }
 
@@ -585,7 +585,7 @@ struct part_iter *pi_begin(const struct disk_info *di, int flags)
     }
 
     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 */
@@ -615,7 +615,7 @@ struct part_iter *pi_begin(const struct disk_info *di, int flags)
                !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;
        }