aboutsummaryrefslogtreecommitdiffstats
path: root/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2018-01-29 00:05:07 +0100
committerArmin Kuster <akuster808@gmail.com>2018-02-11 11:50:56 -0800
commitedbe41f53ec15eeae4673498c41a1f3a42ac813b (patch)
treed27d63b3249b2d4ebfee8ad5e837466d256e7ac2 /meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
parent75356b6a76e965f6e282e8219e88afc1ab4f3240 (diff)
downloadmeta-openembedded-contrib-edbe41f53ec15eeae4673498c41a1f3a42ac813b.tar.gz
ubi-utils-klibc_1.5.2: fix build for qemuarm
Building the recipe with TUNE_FEATURES = "aarch64" and TARGET_FPU = "" fails. See patch headers for more details. Patch sent upstream for master, here rebased for 1.5.2. Tested runtime on armv5. While there backport one more patch fixing warnings in libmtd.c and move the patches in their specific dir, preparing for v2.0.1. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
new file mode 100644
index 0000000000..5bd05742c8
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
@@ -0,0 +1,44 @@
+From e6f1a85c0a3df24fe3ca9a520dc697105e75a80c Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sat, 27 Jan 2018 09:39:26 +0100
+Subject: [PATCH 8/9] ubi-utils: ubiformat.c: convert to integer arithmetic
+
+Do not cast percent to double, it is just used as upper limit.
+Avoid floating point to fix compilation for aarch64 against klibc:
+
+error: '-mgeneral-regs-only' is incompatible with floating-point code
+| int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
+| ^~~~~~~
+
+Notes:
+* The checks in the code above this line ensure that si->good_cnt is not 0.
+
+* The code assumes si->good_cnt * 100 will not overflow, then we can use
+ (si->ok_cnt * 100) safely because the former is bigger.
+
+* The truncated result does not affect the logic:
+ i.e. a value of 49.9 is truncated to 49 and is still <50.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ ubi-utils/ubiformat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
+index 21409ca..d93164a 100644
+--- a/ubi-utils/ubiformat.c
++++ b/ubi-utils/ubiformat.c
+@@ -843,7 +843,7 @@ int main(int argc, char * const argv[])
+ }
+
+ if (!args.override_ec && si->empty_cnt < si->good_cnt) {
+- int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
++ int percent = (si->ok_cnt * 100) / si->good_cnt;
+
+ /*
+ * Make sure the majority of eraseblocks have valid
+--
+2.7.4
+