*: add optimization barrier to all "G trick" locations
[oweals/busybox.git] / util-linux / fdisk.c
index 8271f60f263dfd43e0017731640e820bfe94fd12..827ea21f34a916b7bf7d080e6b8804fcfd666526 100644 (file)
@@ -309,7 +309,7 @@ struct globals {
 #define MBRbuffer       (G.MBRbuffer)
 #define ptes            (G.ptes)
 #define INIT_G() do { \
-       PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
+       SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        sector_size = DEFAULT_SECTOR_SIZE; \
        sector_offset = 1; \
        g_partitions = 4; \
@@ -702,6 +702,7 @@ get_partition_start(const struct pte *pe)
  * We might also do the opposite and warn in all cases except
  * for "is probably nondos partition".
  */
+#ifdef UNUSED
 static int
 is_dos_partition(int t)
 {
@@ -711,6 +712,7 @@ is_dos_partition(int t)
                t == 0x1b || t == 0x1c || t == 0x1e || t == 0x24 ||
                t == 0xc1 || t == 0xc4 || t == 0xc6);
 }
+#endif
 
 static void
 menu(void)
@@ -1734,9 +1736,8 @@ change_sysid(void)
                                "to %x (%s)\n", i + 1, sys,
                                partition_type(sys));
                        ptes[i].changed = 1;
-                       if (is_dos_partition(origsys) ||
-                               is_dos_partition(sys))
-                               //dos_changed = 1;
+                       //if (is_dos_partition(origsys) || is_dos_partition(sys))
+                       //      dos_changed = 1;
                        break;
                }
        }
@@ -2753,7 +2754,6 @@ unknown_command(int c)
 int fdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int fdisk_main(int argc, char **argv)
 {
-       char *str_b, *str_C, *str_H, *str_S;
        unsigned opt;
        /*
         *  fdisk -v
@@ -2775,8 +2775,9 @@ int fdisk_main(int argc, char **argv)
 
        INIT_G();
 
+       opt_complementary = "b+:C+:H+:S+"; /* numeric params */
        opt = getopt32(argv, "b:C:H:lS:u" USE_FEATURE_FDISK_BLKSIZE("s"),
-                               &str_b, &str_C, &str_H, &str_S);
+                               &sector_size, &user_cylinders, &user_heads, &user_sectors);
        argc -= optind;
        argv += optind;
        if (opt & OPT_b) { // -b
@@ -2784,27 +2785,18 @@ int fdisk_main(int argc, char **argv)
                   so cannot be combined with multiple disks,
                   and the same goes for the C/H/S options.
                */
-               sector_size = xatoi_u(str_b);
-               if (sector_size != 512 && sector_size != 1024 &&
-                       sector_size != 2048)
+               if (sector_size != 512 && sector_size != 1024
+                && sector_size != 2048)
                        bb_show_usage();
                sector_offset = 2;
                user_set_sector_size = 1;
        }
-       if (opt & OPT_C) user_cylinders = xatoi_u(str_C); // -C
-       if (opt & OPT_H) { // -H
-               user_heads = xatoi_u(str_H);
-               if (user_heads <= 0 || user_heads >= 256)
-                       user_heads = 0;
-       }
-       //if (opt & OPT_l) // -l
-       if (opt & OPT_S) { // -S
-               user_sectors = xatoi_u(str_S);
-               if (user_sectors <= 0 || user_sectors >= 64)
-                       user_sectors = 0;
-       }
-       if (opt & OPT_u) display_in_cyl_units = 0; // -u
-       //if (opt & OPT_s) // -s
+       if (user_heads <= 0 || user_heads >= 256)
+               user_heads = 0;
+       if (user_sectors <= 0 || user_sectors >= 64)
+               user_sectors = 0;
+       if (opt & OPT_u)
+               display_in_cyl_units = 0; // -u
 
        if (user_set_sector_size && argc != 1)
                printf("Warning: the -b (set sector size) option should"