diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-14 20:05:37 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 04:26:31 +0300 |
commit | eb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch) | |
tree | de291a73dc37168da6370e2cf16c347d1eba9df8 /meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch | |
parent | 9c3cf826d853102535ead04cebc2d6023eff3032 (diff) | |
download | openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz |
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers
content to the top level.
Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-openembedded/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-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch new file mode 100644 index 000000000..36b012f90 --- /dev/null +++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch @@ -0,0 +1,64 @@ +From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001 +From: Andrea Adami <andrea.adami@gmail.com> +Date: Sun, 28 Jan 2018 21:47:59 +0100 +Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic + +We use floating point just to print out KiB, MiB, GiB. +Avoid that to be klibc friendly. + +Fixes compilation for aarch64 against klibc: + +error: '-mgeneral-regs-only' is incompatible with floating-point argument +| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024)); +etc. + +Note: +* In the KiB case, we could apparently multiply by 100 before dividing + without risking overflow. This code simply avoids multiplications. + +Upstream-Status: Submitted + +Signed-off-by: Andrea Adami <andrea.adami@gmail.com> +--- + ubi-utils/ubiutils-common.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c +index 6609a6b..0ded2a4 100644 +--- a/ubi-utils/ubiutils-common.c ++++ b/ubi-utils/ubiutils-common.c +@@ -107,6 +107,9 @@ long long ubiutils_get_bytes(const char *str) + void ubiutils_print_bytes(long long bytes, int bracket) + { + const char *p; ++ int GiB = 1024 * 1024 * 1024; ++ int MiB = 1024 * 1024; ++ int KiB = 1024; + + if (bracket) + p = " ("; +@@ -115,12 +118,15 @@ void ubiutils_print_bytes(long long bytes, int bracket) + + printf("%lld bytes", bytes); + +- if (bytes > 1024 * 1024 * 1024) +- printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024)); +- else if (bytes > 1024 * 1024) +- printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024)); +- else if (bytes > 1024 && bytes != 0) +- printf("%s%.1f KiB", p, (double)bytes / 1024); ++ if (bytes > GiB) ++ printf("%s%lld.%lld GiB", p, ++ bytes / GiB, bytes % GiB / (GiB / 10)); ++ else if (bytes > MiB) ++ printf("%s%lld.%lld MiB", p, ++ bytes / MiB, bytes % MiB / (MiB / 10)); ++ else if (bytes > KiB && bytes != 0) ++ printf("%s%lld.%lld KiB", p, ++ bytes / KiB, bytes % KiB / (KiB / 10)); + else + return; + +-- +2.7.4 + |