git: da04cf02c96b - main - mkimg: Ignore redundant %align values

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 21 Oct 2026 20:48:39 UTC
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=da04cf02c96b97c587580b336fa527392467f689

commit da04cf02c96b97c587580b336fa527392467f689
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-10-17 19:14:16 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-10-21 20:40:38 +0000

    mkimg: Ignore redundant %align values
    
    Partitions are trivially aligned to sector boundaries, so asking e.g.
    for a partition to be aligned to a 64-byte boundary is pointless but
    harmless.  Treat it as such, with a warning (in case the request was
    a mistake, e.g. requesting 1-byte instead of 1M-byte alignment) rather
    than as an error.
    
    Reviewed by:    markj
    Suggested by:   markj
    MFC after:      1 week
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D60819
---
 usr.bin/mkimg/mkimg.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index d8f872b72261..ce0bc98a9f3f 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -516,7 +516,15 @@ mkimg(void)
 			if (expand_number(align, &bytealign) == -1)
 				err(EX_DATAERR, "partition %d",
 				    part->index + 1);
-			if ((bytealign == 0) || (bytealign % secsz != 0))
+			if (bytealign == 0)
+				errx(EX_DATAERR, "partition %d: "
+				    "invalid alignment", part->index + 1);
+			if (secsz % bytealign == 0) {
+				warnx("partition %d: ignoring "
+				    "redundant alignment", part->index + 1);
+				bytealign = secsz;
+			}
+			if (bytealign % secsz != 0)
 				errx(EX_DATAERR, "partition %d: "
 				    "invalid alignment", part->index + 1);
 			blkalign = bytealign / secsz;