aboutsummaryrefslogtreecommitdiffstats
path: root/include/lib/utils_def.h
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-07-18 13:23:07 +0100
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-07-20 11:36:00 +0100
commitf00119de5760d5ed876c17884654da14b877386d (patch)
tree7b211e27ea4cefbe77381f3be5b623242e28d3b7 /include/lib/utils_def.h
parent029f5a28a8dd016e207f1c81bc961674d1528404 (diff)
downloadplatform_external_arm-trusted-firmware-f00119de5760d5ed876c17884654da14b877386d.tar.gz
platform_external_arm-trusted-firmware-f00119de5760d5ed876c17884654da14b877386d.tar.bz2
platform_external_arm-trusted-firmware-f00119de5760d5ed876c17884654da14b877386d.zip
Fix check_[uptr/u32]_overflow() macros MISRA defects
Add missing parentheses to fix MISRA C-2012 Rule 12.1. Also, the result of a comparison is an essentially boolean value, it isn't needed to return 1 or 0 depending on it. Also, fix header guards (MISRA C-2012 Rule 21.1). Change-Id: I90c0bcdeb2787c1ca659fc9a981808ece7958de3 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'include/lib/utils_def.h')
-rw-r--r--include/lib/utils_def.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/lib/utils_def.h b/include/lib/utils_def.h
index 6bc97065c..5b4fd7808 100644
--- a/include/lib/utils_def.h
+++ b/include/lib/utils_def.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __UTILS_DEF_H__
-#define __UTILS_DEF_H__
+#ifndef UTILS_DEF_H
+#define UTILS_DEF_H
/* Compute the number of elements in the given array */
#define ARRAY_SIZE(a) \
@@ -88,15 +88,15 @@
* Evaluates to 1 if (ptr + inc) overflows, 0 otherwise.
* Both arguments must be unsigned pointer values (i.e. uintptr_t).
*/
-#define check_uptr_overflow(ptr, inc) \
- (((ptr) > UINTPTR_MAX - (inc)) ? 1 : 0)
+#define check_uptr_overflow(_ptr, _inc) \
+ ((_ptr) > (UINTPTR_MAX - (_inc)))
/*
* Evaluates to 1 if (u32 + inc) overflows, 0 otherwise.
* Both arguments must be 32-bit unsigned integers (i.e. effectively uint32_t).
*/
-#define check_u32_overflow(u32, inc) \
- ((u32) > (UINT32_MAX - (inc)) ? 1 : 0)
+#define check_u32_overflow(_u32, _inc) \
+ ((_u32) > (UINT32_MAX - (_inc)))
/*
* For those constants to be shared between C and other sources, apply a 'U',
@@ -153,4 +153,4 @@
#define ASSERT_SYM_PTR_ALIGN(sym) assert(((size_t)(sym) % __alignof__(*(sym))) == 0)
-#endif /* __UTILS_DEF_H__ */
+#endif /* UTILS_DEF_H */