summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseSafeIntLib
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2018-02-15 17:09:43 +0100
committerLaszlo Ersek <lersek@redhat.com>2018-02-21 11:57:36 +0100
commit8c33cc0ec926b17396fcd71686c727b991984d4a (patch)
treeb22271ededb8e794434176a9a9f679500f69f558 /MdePkg/Library/BaseSafeIntLib
parent41bfaffd13094d9042110091e6c37adf20c4032c (diff)
downloadedk2-8c33cc0ec926b17396fcd71686c727b991984d4a.tar.gz
edk2-8c33cc0ec926b17396fcd71686c727b991984d4a.tar.bz2
edk2-8c33cc0ec926b17396fcd71686c727b991984d4a.zip
MdePkg/BaseSafeIntLib: clean up parentheses in MIN_INT64_MAGNITUDE
The definition of the MIN_INT64_MAGNITUDE macro is correct, but it's harder to read than necessary: the sub-expression (( (UINT64) - (MIN_INT64 + 1) )) is doubly parenthesized. Reusing one pair of the outer parens, rewrite the sub-expression (without change in meaning) so that the minus sign cannot be mistaken for subtraction: ( (UINT64)(- (MIN_INT64 + 1)) ) The resultant macro definition matches the following expressions in SafeInt64Mult(): > // > // Avoid negating the most negative number. > // > UnsignedMultiplicand = ((UINT64)(- (Multiplicand + 1))) + 1; and > // > // Avoid negating the most negative number. > // > UnsignedMultiplier = ((UINT64)(- (Multiplier + 1))) + 1; Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'MdePkg/Library/BaseSafeIntLib')
-rw-r--r--MdePkg/Library/BaseSafeIntLib/SafeIntLib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c
index 56d97cf656..de91ffeca2 100644
--- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c
+++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c
@@ -33,7 +33,7 @@
//
// Magnitude of MIN_INT64 as expressed by a UINT64 number.
//
-#define MIN_INT64_MAGNITUDE ((((UINT64) - (MIN_INT64 + 1))) + 1)
+#define MIN_INT64_MAGNITUDE (((UINT64)(- (MIN_INT64 + 1))) + 1)
//
// Conversion functions