From 03de2e041c437fc1d211ce6dadf4bb48f8ca89da Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Thu, 17 Sep 2026 11:39:48 +0800 Subject: [PATCH] feat[drivers][block]: fix printf format type mismatches Fix format specifier mismatches in blk_partition.c by using the appropriate integer formats and explicit casts. This removes -Wformat warnings on platforms where rt_uint32_t and rt_size_t are represented as unsigned long. --- components/drivers/block/blk_partition.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/drivers/block/blk_partition.c b/components/drivers/block/blk_partition.c index 5a9e39d15605..b4cbc83bc5b7 100644 --- a/components/drivers/block/blk_partition.c +++ b/components/drivers/block/blk_partition.c @@ -35,11 +35,11 @@ rt_err_t blk_put_partition(struct rt_blk_disk *disk, const char *type, { rt_uint32_t ssz = rt_blk_disk_get_logical_block_size(disk); - rt_kprintf("found part[%u], begin: %lu, size: ", partno, start * ssz); + rt_kprintf("found part[%d], begin: %lu, size: ", partno, (unsigned long)(start * ssz)); if ((count >> 11) == 0) { - rt_kprintf("%u%cB\n", count >> 1, 'K'); /* KB */ + rt_kprintf("%lu%cB\n", (unsigned long)(count >> 1), 'K'); /* KB */ } else { @@ -47,11 +47,11 @@ rt_err_t blk_put_partition(struct rt_blk_disk *disk, const char *type, if ((size_mb >> 10) == 0) { - rt_kprintf("%u.%u%cB\n", size_mb, (count >> 1) & 0x3ff, 'M'); + rt_kprintf("%lu.%lu%cB\n", (unsigned long)size_mb, (unsigned long)((count >> 1) & 0x3ffU), 'M'); } else { - rt_kprintf("%u.%u%cB\n", size_mb >> 10, size_mb & 0x3ff, 'G'); + rt_kprintf("%lu.%lu%cB\n", (unsigned long)(size_mb >> 10), (unsigned long)(size_mb & 0x3ffU), 'G'); } } } @@ -89,8 +89,7 @@ rt_err_t blk_put_partition(struct rt_blk_disk *disk, const char *type, return RT_EOK; _fail: - LOG_E("%s: Put partition.%s[%u] start = %lu count = %lu error = %s", - to_disk_name(disk), type, partno, start, count, rt_strerror(err)); + LOG_E("%s: Put partition.%s[%d] start = %lu count = %lu error = %s", to_disk_name(disk), type, partno, (unsigned long)start, (unsigned long)count, rt_strerror(err)); if (blk) {