[parted-devel] [PATCH 8/8] libparted: optimize _disk_sync_part_table

Petr Uzel petr.uzel at suse.cz
Wed Sep 28 08:45:09 UTC 2011


In _disk_sync_part_table, if the largest partition number (lpn) is
0, it does not make sense to go through the loops below. Return
immediately instead.

* libparted/arch/linux.c (_disk_sync_part_table): Return immediately
if lpn == 0.

Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
 libparted/arch/linux.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index b6f7e0b..216fe8b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2475,7 +2475,7 @@ _disk_sync_part_table (PedDisk* disk)
         /* Its not possible to support largest_partnum < 0.
          * largest_partnum == 0 would mean does not support partitions.
          * */
-        if (lpn < 0)
+        if (lpn < 1)
                 return 0;
         int ret = 0;
         int *ok = calloc (lpn, sizeof *ok);
-- 
1.7.3.4




More information about the parted-devel mailing list