[parted-devel] [PATCH] fix off-by-one displaying disklabel info

David Cantrell dcantrell at redhat.com
Mon Apr 23 20:06:17 UTC 2007


commit 11c7ff4b394ee9eeed9734bb05a9c87996fef15c
Author: David Cantrell <dcantrel at mortise.boston.redhat.com>
Date:   Mon Apr 23 16:00:54 2007 -0400

    Fix off-by-one bug in parted when displaying information about the
disk label (the disk size, specifically).

diff --git a/parted/parted.c b/parted/parted.c
index 25fbf5d..598cdcc 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1240,6 +1240,7 @@ partition_print (PedPartition* part)
 static int
 do_print (PedDevice** dev)
 {
+        PedUnit         default_unit;
         PedDisk*        disk;
         Table*          table;
         StrList*        row;
@@ -1326,11 +1327,13 @@ do_print (PedDevice** dev)
         }
 
         start = ped_unit_format (*dev, 0);
+        default_unit = ped_unit_get_default ();
         end = ped_unit_format_byte (*dev, (*dev)->length *
(*dev)->sector_size
-                                          - 1 );
-        
+                                    - (default_unit == PED_UNIT_CHS ||
+                                       default_unit ==
PED_UNIT_CYLINDER));
+
         if (opt_machine_mode) {
-            switch (ped_unit_get_default ()) {
+            switch (default_unit) {
                 case PED_UNIT_CHS:      puts ("CHS;");
                                         break;
                 case PED_UNIT_CYLINDER: puts ("CYL;");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20070423/1a2f3f0c/attachment.pgp


More information about the parted-devel mailing list