From 5528c84c0314c66a1bbf8332b26c69331c2ce44b Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 19 May 2023 06:16:35 +0800 Subject: [PATCH] fs/partition: MBR parser should initialize blocksize field Signed-off-by: Xiang Xiao --- fs/partition/fs_gpt.c | 4 ++-- fs/partition/fs_mbr.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/partition/fs_gpt.c b/fs/partition/fs_gpt.c index acce18c404..fe75f55e00 100644 --- a/fs/partition/fs_gpt.c +++ b/fs/partition/fs_gpt.c @@ -40,7 +40,7 @@ #define GPT_BLOCK_SIZE 512 #define GPT_HEADER_SIGNATURE 0x5452415020494645ull #define GPT_PARTNAME_MAX_SIZE (72 / sizeof(uint16_t)) -#define GPT_LBA_TO_BLOCK(lba, blk) ((le64toh(lba) * 512 + (blk) -1) / (blk)) +#define GPT_LBA_TO_BLOCK(lba, blk) ((le64toh(lba) * 512 + (blk) - 1) / (blk)) /**************************************************************************** * Private Types @@ -204,7 +204,7 @@ gpt_alloc_verify_entries(FAR struct partition_state_s *state, return NULL; } - blk = (size + (state->blocksize -1)) / state->blocksize; + blk = (size + (state->blocksize - 1)) / state->blocksize; pte = kmm_zalloc(blk * state->blocksize); if (!pte) { diff --git a/fs/partition/fs_mbr.c b/fs/partition/fs_mbr.c index 2e2effcd78..672c9d76da 100644 --- a/fs/partition/fs_mbr.c +++ b/fs/partition/fs_mbr.c @@ -136,6 +136,7 @@ int parse_mbr_partition(FAR struct partition_state_s *state, state->blocksize); pentry.nblocks = MBR_LBA_TO_BLOCK(table[i].partition_size, state->blocksize); + pentry.blocksize = state->blocksize; if (pentry.nblocks != 0) {