summaryrefslogtreecommitdiffstats
path: root/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch64
1 files changed, 0 insertions, 64 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
deleted file mode 100644
index 36b012f90..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 28 Jan 2018 21:47:59 +0100
4Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic
5
6We use floating point just to print out KiB, MiB, GiB.
7Avoid that to be klibc friendly.
8
9Fixes compilation for aarch64 against klibc:
10
11error: '-mgeneral-regs-only' is incompatible with floating-point argument
12| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
13etc.
14
15Note:
16* In the KiB case, we could apparently multiply by 100 before dividing
17 without risking overflow. This code simply avoids multiplications.
18
19Upstream-Status: Submitted
20
21Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
22---
23 ubi-utils/ubiutils-common.c | 18 ++++++++++++------
24 1 file changed, 12 insertions(+), 6 deletions(-)
25
26diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c
27index 6609a6b..0ded2a4 100644
28--- a/ubi-utils/ubiutils-common.c
29+++ b/ubi-utils/ubiutils-common.c
30@@ -107,6 +107,9 @@ long long ubiutils_get_bytes(const char *str)
31 void ubiutils_print_bytes(long long bytes, int bracket)
32 {
33 const char *p;
34+ int GiB = 1024 * 1024 * 1024;
35+ int MiB = 1024 * 1024;
36+ int KiB = 1024;
37
38 if (bracket)
39 p = " (";
40@@ -115,12 +118,15 @@ void ubiutils_print_bytes(long long bytes, int bracket)
41
42 printf("%lld bytes", bytes);
43
44- if (bytes > 1024 * 1024 * 1024)
45- printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
46- else if (bytes > 1024 * 1024)
47- printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024));
48- else if (bytes > 1024 && bytes != 0)
49- printf("%s%.1f KiB", p, (double)bytes / 1024);
50+ if (bytes > GiB)
51+ printf("%s%lld.%lld GiB", p,
52+ bytes / GiB, bytes % GiB / (GiB / 10));
53+ else if (bytes > MiB)
54+ printf("%s%lld.%lld MiB", p,
55+ bytes / MiB, bytes % MiB / (MiB / 10));
56+ else if (bytes > KiB && bytes != 0)
57+ printf("%s%lld.%lld KiB", p,
58+ bytes / KiB, bytes % KiB / (KiB / 10));
59 else
60 return;
61
62--
632.7.4
64