ext4_mbr: improve printf formatting
authorgkostka <kostka.grzegorz@gmail.com>
Tue, 8 Dec 2015 19:32:15 +0000 (20:32 +0100)
committergkostka <kostka.grzegorz@gmail.com>
Tue, 8 Dec 2015 19:32:15 +0000 (20:32 +0100)
fs_test/lwext4_mbr.c
lwext4/ext4_mbr.c

index dbf5d8161ab8b9d9373a353167bc43c0607dc2aa..8c37c09cd86a505d9b8e8de01658317e0c3dc5ef 100644 (file)
@@ -170,10 +170,10 @@ int main(int argc, char **argv)
                        continue;
                }
 
-               printf("\toffeset: 0x%llx, %lluMB\n",
+               printf("\toffeset: 0x%"PRIx64", %"PRIu64"MB\n",
                        bdevs.partitions[i].part_offset,
                        bdevs.partitions[i].part_offset / (1024 * 1024));
-               printf("\tsize: 0x%llx, %lluMB\n",
+               printf("\tsize:    0x%"PRIx64", %"PRIu64"MB\n",
                        bdevs.partitions[i].part_size,
                        bdevs.partitions[i].part_size / (1024 * 1024));
        }
index e394ab28020df05d613eff40e416d5e8ae0f3aac..cd2fa51a0b94480ecd35105062abf3431b4fddfd 100644 (file)
@@ -39,6 +39,7 @@
 #include "ext4_debug.h"
 #include "ext4_mbr.h"
 
+#include <inttypes.h>
 #include <string.h>
 
 #define MBR_SIGNATURE 0xAA55
@@ -90,20 +91,20 @@ int ext4_mbr_scan(struct ext4_blockdev *parent, struct ext4_mbr_bdevs *bdevs)
                ext4_dbg(DEBUG_MBR, "mbr_part: %d\n", i);
                ext4_dbg(DEBUG_MBR, "\tstatus: 0x%x\n", pe->status);
                ext4_dbg(DEBUG_MBR, "\ttype 0x%x:\n", pe->type);
-               ext4_dbg(DEBUG_MBR, "\tfirst_lba: 0x%x\n", pe->first_lba);
-               ext4_dbg(DEBUG_MBR, "\tsectors: 0x%x\n", pe->sectors);
+               ext4_dbg(DEBUG_MBR, "\tfirst_lba: 0x%"PRIx32"\n", pe->first_lba);
+               ext4_dbg(DEBUG_MBR, "\tsectors: 0x%"PRIx32"\n", pe->sectors);
 
                if (!pe->sectors)
-                       continue;
+                       continue; /*Empty entry*/
 
                if (pe->type != 0x83)
-                       continue;
+                       continue; /*Unsupported entry. 0x83 - linux native*/
 
                bdevs->partitions[i].bdif = parent->bdif;
                bdevs->partitions[i].part_offset =
-                               pe->first_lba * parent->bdif->ph_bsize;
+                       (uint64_t)pe->first_lba * parent->bdif->ph_bsize;
                bdevs->partitions[i].part_size =
-                               (uint64_t)pe->sectors * parent->bdif->ph_bsize;
+                       (uint64_t)pe->sectors * parent->bdif->ph_bsize;
        }
 
        blockdev_fini: