summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/partition.c
diff options
context:
space:
mode:
authorKarel Zak2014-12-04 10:27:39 +0100
committerKarel Zak2014-12-04 10:27:39 +0100
commit19ff8ff7c448e4e88e602dde0af4230bff5b4daa (patch)
tree489b3709b6c98b9970dc5fc97cb68079f29db6cc /libfdisk/src/partition.c
parentlsblk: add SUBSYSTEMS column (diff)
downloadkernel-qcow2-util-linux-19ff8ff7c448e4e88e602dde0af4230bff5b4daa.tar.gz
kernel-qcow2-util-linux-19ff8ff7c448e4e88e602dde0af4230bff5b4daa.tar.xz
kernel-qcow2-util-linux-19ff8ff7c448e4e88e602dde0af4230bff5b4daa.zip
libfdisk: fix cfdisk freespace analyze
The problem is how fdisk_partition_cmp_start() compare numbers, the function returns result from "a->start - b->start", unfortunately the numbers are uint64, but function returns "int". Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/partition.c')
-rw-r--r--libfdisk/src/partition.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 7d4d57669..90276416e 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -180,7 +180,17 @@ int fdisk_partition_has_start(struct fdisk_partition *pa)
int fdisk_partition_cmp_start(struct fdisk_partition *a,
struct fdisk_partition *b)
{
- return a->start - b->start;
+ int is_a = FDISK_IS_UNDEF(a->start),
+ is_b = FDISK_IS_UNDEF(b->start);
+
+ if (!is_a && !is_b)
+ return 0;
+ if (!is_a)
+ return -1;
+ if (!is_b)
+ return 1;
+
+ return cmp_numbers(a->start, b->start);
}
/**