]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
authorPierre Gondois <Pierre.Gondois@arm.com>
Thu, 10 Dec 2020 10:11:59 +0000 (10:11 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 6 Jan 2021 16:22:54 +0000 (16:22 +0000)
This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Brackets are also added to comply to with the coding
standard.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
ArmPkg/Library/CompilerIntrinsicsLib/memset.c
ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c

index 551f8e77c12f37b16cbca646267bb46ba478b4dd..e6b34b273bd2cc4b28426f72211ba1b5ac6c0995 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2019, Pete Batard. All rights reserved.\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -20,7 +21,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
   unsigned char const *t1 = s1;\r
   unsigned char const *t2 = s2;\r
 \r
-  while (n--) {\r
+  while (n-- != 0) {\r
     if (*t1 != *t2)\r
       return (int)*t1 - (int)*t2;\r
     t1++;\r
index 6e9c85f4bafd6f564fcaeed7935c9714b0530e34..942b888e3d0644acd43eea6251be4277b420c69a 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -13,8 +14,9 @@ static void __memcpy(void *dest, const void *src, size_t n)
   unsigned char *d = dest;\r
   unsigned char const *s = src;\r
 \r
-  while (n--)\r
+  while (n-- != 0) {\r
     *d++ = *s++;\r
+  }\r
 }\r
 \r
 void *memcpy(void *dest, const void *src, size_t n)\r
index 34feef5a4bb90ccee49caf5e868732d4c8a96b26..fe5b1d04c7c21451c085fa6fdf51347709b18ae8 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2017, Pete Batard. All rights reserved.<BR>\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -20,8 +21,9 @@ void* memcpy(void *dest, const void *src, size_t n)
   unsigned char *d = dest;\r
   unsigned char const *s = src;\r
 \r
-  while (n--)\r
+  while (n-- != 0) {\r
     *d++ = *s++;\r
+  }\r
 \r
   return dest;\r
 }\r
index 5b261ef8b948a5b04f67b8702ddaa299a5a0140b..3a8e3e967f41734843438d402b11ddf6dd3af804 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2019, Pete Batard. All rights reserved.\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -21,13 +22,15 @@ void* memmove(void *dest, const void *src, size_t n)
   unsigned char const *s = src;\r
 \r
   if (d < s) {\r
-    while (n--)\r
+    while (n-- != 0) {\r
       *d++ = *s++;\r
+    }\r
   } else {\r
     d += n;\r
     s += n;\r
-    while (n--)\r
+    while (n-- != 0) {\r
       *--d = *--s;\r
+    }\r
   }\r
 \r
   return dest;\r
index 24398d591f79a48025235a4c3b78df655bc19b0b..1a36aeaa5684f0b387d3b9bfbeb695d96a2e6695 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -13,8 +14,9 @@ void *__memset(void *s, int c, size_t n)
 {\r
   unsigned char *d = s;\r
 \r
-  while (n--)\r
+  while (n-- != 0) {\r
     *d++ = c;\r
+  }\r
 \r
   return s;\r
 }\r
index 4de55d845718ca3b59232e870639a55b05d8f543..c046b8be8606fba26a7045a25436afc5ea2abdfc 100644 (file)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2017, Pete Batard. All rights reserved.<BR>\r
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -19,8 +20,9 @@ void *memset(void *s, int c, size_t n)
 {\r
   unsigned char *d = s;\r
 \r
-  while (n--)\r
+  while (n-- != 0) {\r
     *d++ = (unsigned char)c;\r
+  }\r
 \r
   return s;\r
 }\r