From 70d341b507b54ac205ea88f6ba0129fd30306e00 Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Tue, 9 Jun 2026 21:15:52 +0800 Subject: [PATCH] repart: fix SizeMinBytes/SizeMaxBytes rounding direction The ltype parameter for SizeMinBytes and SizeMaxBytes in the config parsing table was reversed. SizeMinBytes should round UP (ltype > 0) to ensure the partition is at least the specified size, while SizeMaxBytes should round DOWN (ltype < 0) to ensure the partition doesn't exceed the specified size. This matches the documentation in repart.d.xml which correctly states: - SizeMinBytes: 'rounded upwards' - SizeMaxBytes: 'rounded downwards' The same fix is applied to PaddingMinBytes and PaddingMaxBytes which share the same config_parse_size4096 parser. Fixes: #42526 Co-developed-by: Claude Opus 4.6 Signed-off-by: Liu Zhangjian --- src/repart/repart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/repart/repart.c b/src/repart/repart.c index f202007674..1095a81dfb 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -2929,10 +2929,10 @@ static int partition_read_definition( { "Partition", "Priority", config_parse_int32, 0, &p->priority }, { "Partition", "Weight", config_parse_weight, 0, &p->weight }, { "Partition", "PaddingWeight", config_parse_weight, 0, &p->padding_weight }, - { "Partition", "SizeMinBytes", config_parse_size4096, -1, &p->size_min }, - { "Partition", "SizeMaxBytes", config_parse_size4096, 1, &p->size_max }, - { "Partition", "PaddingMinBytes", config_parse_size4096, -1, &p->padding_min }, - { "Partition", "PaddingMaxBytes", config_parse_size4096, 1, &p->padding_max }, + { "Partition", "SizeMinBytes", config_parse_size4096, 1, &p->size_min }, + { "Partition", "SizeMaxBytes", config_parse_size4096, -1, &p->size_max }, + { "Partition", "PaddingMinBytes", config_parse_size4096, 1, &p->padding_min }, + { "Partition", "PaddingMaxBytes", config_parse_size4096, -1, &p->padding_max }, { "Partition", "FactoryReset", config_parse_bool, 0, &p->factory_reset }, { "Partition", "CopyBlocks", config_parse_copy_blocks, 0, p }, { "Partition", "Format", config_parse_fstype, 0, &p->format },