diff options
author | Pierre Gondois <Pierre.Gondois@arm.com> | 2020-12-10 10:11:59 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-01-06 16:22:54 +0000 |
commit | 53aabb978e133d1c58fd60c693eecf836a8efe38 (patch) | |
tree | b70c0cdb70bafccb7710d985092841b324f2fcd6 | |
parent | e3fe63ddebfb673b01ced64ce8091b54d65ec053 (diff) | |
download | edk2-53aabb978e133d1c58fd60c693eecf836a8efe38.tar.gz edk2-53aabb978e133d1c58fd60c693eecf836a8efe38.tar.bz2 edk2-53aabb978e133d1c58fd60c693eecf836a8efe38.zip |
ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
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>
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c | 3 | ||||
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c | 4 | ||||
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 4 | ||||
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 7 | ||||
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memset.c | 4 | ||||
-rw-r--r-- | ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 4 |
6 files changed, 19 insertions, 7 deletions
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c index 551f8e77c1..e6b34b273b 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2019, Pete Batard. All rights reserved.
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -20,7 +21,7 @@ int memcmp(const void *s1, const void *s2, size_t n) unsigned char const *t1 = s1;
unsigned char const *t2 = s2;
- while (n--) {
+ while (n-- != 0) {
if (*t1 != *t2)
return (int)*t1 - (int)*t2;
t1++;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c index 6e9c85f4ba..942b888e3d 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -13,8 +14,9 @@ static void __memcpy(void *dest, const void *src, size_t n) unsigned char *d = dest;
unsigned char const *s = src;
- while (n--)
+ while (n-- != 0) {
*d++ = *s++;
+ }
}
void *memcpy(void *dest, const void *src, size_t n)
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c index 34feef5a4b..fe5b1d04c7 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -20,8 +21,9 @@ void* memcpy(void *dest, const void *src, size_t n) unsigned char *d = dest;
unsigned char const *s = src;
- while (n--)
+ while (n-- != 0) {
*d++ = *s++;
+ }
return dest;
}
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c index 5b261ef8b9..3a8e3e967f 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2019, Pete Batard. All rights reserved.
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -21,13 +22,15 @@ void* memmove(void *dest, const void *src, size_t n) unsigned char const *s = src;
if (d < s) {
- while (n--)
+ while (n-- != 0) {
*d++ = *s++;
+ }
} else {
d += n;
s += n;
- while (n--)
+ while (n-- != 0) {
*--d = *--s;
+ }
}
return dest;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c index 24398d591f..1a36aeaa56 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -13,8 +14,9 @@ void *__memset(void *s, int c, size_t n) {
unsigned char *d = s;
- while (n--)
+ while (n-- != 0) {
*d++ = c;
+ }
return s;
}
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c index 4de55d8457..c046b8be86 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------
//
// Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
+// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
@@ -19,8 +20,9 @@ void *memset(void *s, int c, size_t n) {
unsigned char *d = s;
- while (n--)
+ while (n-- != 0) {
*d++ = (unsigned char)c;
+ }
return s;
}
|