[parted-devel] [PATCH] libparted: Use llabs for long long
Will Newton
will.newton at gmail.com
Fri Jul 21 13:21:32 UTC 2017
Use llabs rather than abs for long long values.
Signed-off-by: Will Newton <willn at resin.io>
---
libparted/cs/natmath.c | 2 +-
libparted/disk.c | 2 +-
libparted/filesys.c | 2 +-
libparted/labels/dos.c | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libparted/cs/natmath.c b/libparted/cs/natmath.c
index 74d3213..b0bb862 100644
--- a/libparted/cs/natmath.c
+++ b/libparted/cs/natmath.c
@@ -432,7 +432,7 @@ closest (PedSector sector, PedSector a, PedSector b)
if (b == -1)
return a;
- if (abs (sector - a) < abs (sector - b))
+ if (llabs (sector - a) < llabs (sector - b))
return a;
else
return b;
diff --git a/libparted/disk.c b/libparted/disk.c
index fe82f44..959a2a9 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -615,7 +615,7 @@ ped_disk_check (const PedDisk* disk)
if (!geom)
continue;
- length_error = abs (walk->geom.length - geom->length);
+ length_error = llabs (walk->geom.length - geom->length);
max_length_error = PED_MAX (4096, walk->geom.length / 100);
bool ok = (ped_geometry_test_inside (&walk->geom, geom)
&& length_error <= max_length_error);
diff --git a/libparted/filesys.c b/libparted/filesys.c
index 0f8e821..0012466 100644
--- a/libparted/filesys.c
+++ b/libparted/filesys.c
@@ -211,7 +211,7 @@ _geometry_error (const PedGeometry* a, const PedGeometry* b)
PedSector start_delta = a->start - b->start;
PedSector end_delta = a->end - b->end;
- return abs (start_delta) + abs (end_delta);
+ return llabs (start_delta) + llabs (end_delta);
}
static PedFileSystemType*
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index fa53020..c1009db 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -1731,8 +1731,8 @@ _best_solution (const PedPartition* part, const PedCHSGeometry* bios_geom,
PedSector a_delta;
PedSector b_delta;
- a_delta = abs (part->geom.start - a->start);
- b_delta = abs (part->geom.start - b->start);
+ a_delta = llabs (part->geom.start - a->start);
+ b_delta = llabs (part->geom.start - b->start);
if (a_delta < b_delta)
goto choose_a;
--
2.9.4
More information about the parted-devel
mailing list