gpu: nvgpu: fix CERT-C violations in utils unit

INT31-C requires that integer conversions do not result in lost or
misinterpreted data.  Fix violations of INT31-C in utils unit.

Jira NVGPU-3609

Change-Id: Iacf62957b6a3a84ac99e35109f3324ace2ea9454
Signed-off-by: ajesh <akv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2161334
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
ajesh
2019-07-25 20:00:37 +05:30
committed by mobile promotions
parent e58e00b0fb
commit 5798894b68

View File

@@ -195,8 +195,8 @@ static inline unsigned int nvgpu_posix_hweight16(uint16_t x)
{
unsigned int ret;
ret = nvgpu_posix_hweight8((uint8_t)x);
ret += nvgpu_posix_hweight8((uint8_t)((x & 0xff00U) >> 8));
ret = nvgpu_posix_hweight8((uint8_t)(x & U8(0xff)));
ret += nvgpu_posix_hweight8((uint8_t)((x >> U8(8)) & U8(0xff)));
return ret;
}
@@ -205,8 +205,8 @@ static inline unsigned int nvgpu_posix_hweight32(uint32_t x)
{
unsigned int ret;
ret = nvgpu_posix_hweight16((uint16_t)x);
ret += nvgpu_posix_hweight16((uint16_t)((x & 0xffff0000U) >> 16));
ret = nvgpu_posix_hweight16((uint16_t)(x & U16(0xffff)));
ret += nvgpu_posix_hweight16((uint16_t)((x >> U16(16)) & U16(0xffff)));
return ret;
}