]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (dos) use size-=1 when alignment not used later
authorKarel Zak <kzak@redhat.com>
Tue, 22 Aug 2017 12:54:27 +0000 (14:54 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 20 Sep 2017 12:20:53 +0000 (14:20 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/dos.c

index 44d02215521808a68d4588ab72f9f63ccb64ff85..e5deedf2c7e79cc7518da284a3b0c8e561341dbd 100644 (file)
@@ -1181,7 +1181,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
        else if (pa && fdisk_partition_has_size(pa)) {
                stop = start + pa->size;
                isrel = pa->size_explicit ? 0 : 1;
-               if (!isrel && stop > start)
+               if ((!isrel || !alignment_required(cxt)) && stop > start)
                        stop -= 1;
        } else {
                /* ask user by dialog */
@@ -1227,7 +1227,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
                }
        }
 
-       DBG(LABEL, ul_debug("DOS: raw stop: %ju", (uintmax_t) stop));
+       DBG(LABEL, ul_debug("DOS: raw stop: %ju [limit %ju]", (uintmax_t) stop, (uintmax_t) limit));
 
        if (stop > limit)
                stop = limit;
@@ -1237,7 +1237,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
                isrel = 0;
                if (stop > start)
                        stop -= 1;
-               DBG(LABEL, ul_debug("DOS: don't align end os tiny partition [start=%ju, stop=%ju, grain=%lu]",
+               DBG(LABEL, ul_debug("DOS: don't align end of tiny partition [start=%ju, stop=%ju, grain=%lu]",
                            (uintmax_t)start,  (uintmax_t)stop, cxt->grain));
        }