[dpdk-dev] [PATCH] eal/x86: Fix build with clang for old AVX

Zhihong Wang zhihong.wang at intel.com
Thu Feb 4 03:12:34 CET 2016


When configuring RTE_MACHINE to "default", rte_memcpy implementation
is the default one (old AVX).
In this code, clang raises a warning thanks to -Wsometimes-uninitialized:

rte_memcpy.h:838:6: error:
variable 'srcofs' is used uninitialized whenever 'if' condition is false
        if (dstofss > 0) {
            ^~~~~~~~~~~
rte_memcpy.h:849:6: note: uninitialized use occurs here
        if (srcofs == 0) {
            ^~~~~~

It is fixed by moving srcofs initialization out of the condition.
Also dstofss calculation is corrected.

Fixes: 1ae817f9f887 ("eal/x86: tune memcpy for platforms without AVX512")

Signed-off-by: Zhihong Wang <zhihong.wang at intel.com>
Reported-by: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
---
 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 8e2c53c..f463ab3 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -512,8 +512,9 @@ COPY_BLOCK_64_BACK31:
 	/**
 	 * Make store aligned when copy size exceeds 512 bytes
 	 */
-	dstofss = 32 - ((uintptr_t)dst & 0x1F);
+	dstofss = (uintptr_t)dst & 0x1F;
 	if (dstofss > 0) {
+		dstofss = 32 - dstofss;
 		n -= dstofss;
 		rte_mov32((uint8_t *)dst, (const uint8_t *)src);
 		src = (const uint8_t *)src + dstofss;
@@ -834,14 +835,15 @@ COPY_BLOCK_64_BACK15:
 	 * unaligned copy functions require up to 15 bytes
 	 * backwards access.
 	 */
-	dstofss = 16 - ((uintptr_t)dst & 0x0F) + 16;
+	dstofss = (uintptr_t)dst & 0x0F;
 	if (dstofss > 0) {
+		dstofss = 16 - dstofss + 16;
 		n -= dstofss;
 		rte_mov32((uint8_t *)dst, (const uint8_t *)src);
 		src = (const uint8_t *)src + dstofss;
 		dst = (uint8_t *)dst + dstofss;
-		srcofs = ((uintptr_t)src & 0x0F);
 	}
+	srcofs = ((uintptr_t)src & 0x0F);
 
 	/**
 	 * For aligned copy
-- 
2.5.0



More information about the dev mailing list