From 54c43f480901d3fd4de2bdb0e65811a836456945 Mon Sep 17 00:00:00 2001 From: Shaileshwar M Date: Thu, 8 Aug 2024 10:21:06 +0100 Subject: [PATCH] framework: update FWK_IS_VALUE_POWER_OF_TWO macro Modify the FWK_IS_VALUE_POWER_OF_TWO macro to address cppcheck warnings encountered with unsigned integers in the previous version. The revised macro ensures proper handling of both signed and unsigned integers by checking if a value is positive and a power of two. The specific cppcheck warning encountered was: "Checking if unsigned expression 'page_size' is less than zero. [unsignedLessThanZero]." Change-Id: I59c42016f207956ec07f557714cadd946ad58a91 --- framework/include/fwk_macros.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/include/fwk_macros.h b/framework/include/fwk_macros.h index de43e9a89..9bb8b44fc 100644 --- a/framework/include/fwk_macros.h +++ b/framework/include/fwk_macros.h @@ -40,8 +40,7 @@ * \retval False when the \p VALUE is not power of two. */ #define FWK_IS_VALUE_POWER_OF_TWO(VALUE) \ - ((VALUE) <= 0) ? false : (((VALUE) & ((VALUE)-1)) == (0)) - + (((VALUE) > 0) && (((VALUE) & ((VALUE)-1)) == 0)) /*! * \brief Aligns a value to the next multiple. * -- GitLab