From 764ff429ac913567910e4acb1da98502f246754a Mon Sep 17 00:00:00 2001 From: Dmitry Shkurko Date: Wed, 28 Aug 2013 19:33:24 +0700 Subject: Avoid integer overflow while calculating max values BZ: 134249 The behavior is undefined in the case of signed integer overflow for enum and fixed point parameter types. Modify the behavior to handle correctly the signed integers. Change-Id: Idbd0798a39f826853ae1afcd05cebd897675b9a8 Signed-off-by: Dmitry Shkurko --- parameter/FixedPointParameterType.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'parameter/FixedPointParameterType.cpp') diff --git a/parameter/FixedPointParameterType.cpp b/parameter/FixedPointParameterType.cpp index 3c9e20f..2b97f58 100644 --- a/parameter/FixedPointParameterType.cpp +++ b/parameter/FixedPointParameterType.cpp @@ -271,8 +271,6 @@ void CFixedPointParameterType::getRange(double& dMin, double& dMax) const // Out of range error string CFixedPointParameterType::getOutOfRangeError(const string& strValue, bool bRawValueSpace, bool bHexaValue) const { - - ostringstream strStream; strStream << "Value " << strValue << " standing out of admitted "; @@ -288,7 +286,7 @@ string CFixedPointParameterType::getOutOfRangeError(const string& strValue, bool } else { // Min/Max computation - int32_t iMax = (1L << (getSize() * 8 - 1)) - 1; + int32_t iMax = getMaxValue(); int32_t iMin = -iMax - 1; strStream << "raw range ["; -- cgit v1.1