]> err.no Git - util-linux/commitdiff
fdisk: fix default first sector
authorKarel Zak <kzak@redhat.com>
Tue, 9 Feb 2010 10:06:42 +0000 (11:06 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Feb 2010 08:58:57 +0000 (09:58 +0100)
The previous release 2.17 introduces aligned defaults for the first
and last sectors on the partition. Unfortunately, there is endless
loop when the code looks for first unused aligned sector.

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisk.c

index dc5dfb9d9005333f1a7a433f770a86ecec45666c..ddfd24d1ecdd8f690fbff417bc72503405b8bf00 100644 (file)
@@ -2309,17 +2309,16 @@ add_partition(int n, int sys) {
 
        snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR));
        do {
-               unsigned long long dflt, dflt_tmp;
+               unsigned long long dflt, aligned;
 
                temp = start;
-
                dflt = start = get_unused_start(n, start, first, last);
 
                /* the default sector should be aligned and unused */
                do {
-                       dflt_tmp = align_lba_in_range(dflt, start, limit);
-                       dflt = get_unused_start(n, dflt_tmp, first, last);
-               } while (dflt != dflt_tmp && dflt > dflt_tmp && dflt < limit);
+                       aligned = align_lba_in_range(dflt, dflt, limit);
+                       dflt = get_unused_start(n, aligned, first, last);
+               } while (dflt != aligned && dflt > aligned && dflt < limit);
 
                if (dflt >= limit)
                        dflt = start;