You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/05/27 23:23:23 UTC

[nuttx] 01/02: fs/partition: MBR parser should initialize blocksize field

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 5528c84c0314c66a1bbf8332b26c69331c2ce44b
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 19 06:16:35 2023 +0800

    fs/partition: MBR parser should initialize blocksize field
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 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)
         {