|
@@ -0,0 +1,72 @@
|
|
|
+From 88714fc174b91950c9e1c53a9832fc6d4ffa6e2a Mon Sep 17 00:00:00 2001
|
|
|
+From: Etienne Carriere <etienne.carriere@linaro.org>
|
|
|
+Date: Sun, 17 Feb 2019 22:44:44 +0100
|
|
|
+Subject: [PATCH] regression 4100: update string conversion loop
|
|
|
+
|
|
|
+Change the loop used to convert string into numerical value.
|
|
|
+The original loop was fine but its implementation hits toolchain
|
|
|
+unsafe-loop-optimizations feature. The new implementation
|
|
|
+proposed here simplifies a bit the loop and prevents toolchain
|
|
|
+from complaining when directive -Werror=unsafe-loop-optimizations
|
|
|
+is enabled.
|
|
|
+
|
|
|
+Issue reported by the Buildroot cross toolchain [1] with the
|
|
|
+following error traces:
|
|
|
+
|
|
|
+build/armv7/build/optee-test-3.4.0/host/xtest/regression_4100.c:447:8: error: missed loop optimization, the loop counter may overflow [-Werror=unsafe-loop-optimizations]
|
|
|
+ while (spos) {
|
|
|
+ ^
|
|
|
+build/optee-test-3.4.0/host/xtest/regression_4100.c:454:6: error: missed loop optimization, the loop counter may overflow [-Werror=unsafe-loop-optimizations]
|
|
|
+ if (!spos)
|
|
|
+ ^
|
|
|
+
|
|
|
+[1] arm-buildroot-linux-uclibcgnueabihf-gcc.br_real (Buildroot 2019.02-git-00933-gb75e93c) 7.4.0
|
|
|
+
|
|
|
+Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
|
|
|
+---
|
|
|
+ host/xtest/regression_4100.c | 25 ++++++++++++++-----------
|
|
|
+ 1 file changed, 14 insertions(+), 11 deletions(-)
|
|
|
+
|
|
|
+diff --git a/host/xtest/regression_4100.c b/host/xtest/regression_4100.c
|
|
|
+index b477f38..88346d4 100644
|
|
|
+--- a/host/xtest/regression_4100.c
|
|
|
++++ b/host/xtest/regression_4100.c
|
|
|
+@@ -445,21 +445,24 @@ static TEEC_Result convert_from_string(ADBG_Case_t *c, TEEC_Session *s,
|
|
|
+ return TEEC_ERROR_OUT_OF_MEMORY;
|
|
|
+
|
|
|
+ while (spos) {
|
|
|
+- spos--;
|
|
|
+- nibble = digit_value(str[spos]);
|
|
|
+- if (nibble == -1)
|
|
|
++ nibble = digit_value(str[spos - 1]);
|
|
|
++ if (nibble == -1) {
|
|
|
++ spos--;
|
|
|
+ break;
|
|
|
++ }
|
|
|
+ os[ospos] = nibble;
|
|
|
+
|
|
|
+- if (!spos)
|
|
|
+- break;
|
|
|
++ if (spos > 1) {
|
|
|
++ nibble = digit_value(str[spos - 2]);
|
|
|
++ if (nibble == -1) {
|
|
|
++ spos -= 2;
|
|
|
++ break;
|
|
|
++ }
|
|
|
++ os[ospos] |= nibble << 4;
|
|
|
++ ospos--;
|
|
|
++ spos--;
|
|
|
++ }
|
|
|
+ spos--;
|
|
|
+- nibble = digit_value(str[spos]);
|
|
|
+- if (nibble == -1)
|
|
|
+- break;
|
|
|
+-
|
|
|
+- os[ospos] |= nibble << 4;
|
|
|
+- ospos--;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (spos)
|
|
|
+--
|
|
|
+2.20.1
|
|
|
+
|