gpu: nvgpu: fix certc 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: I6d216fc76b2c84f81a0fc0f67822e6bc632b8397
Signed-off-by: ajesh <akv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2169861
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Alex Waterman <alexw@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-08-07 11:41:19 +05:30
committed by mobile promotions
parent 149f9d826a
commit 0f19ccb402

View File

@@ -214,10 +214,13 @@ static inline unsigned int nvgpu_posix_hweight32(uint32_t x)
static inline unsigned int nvgpu_posix_hweight64(uint64_t x)
{
unsigned int ret;
u32 lo, hi;
ret = nvgpu_posix_hweight32((uint32_t)x);
ret += nvgpu_posix_hweight32((uint32_t)((x &
0xffffffff00000000U) >> 32));
lo = nvgpu_safe_cast_u64_to_u32(x & ~(u32)0);
hi = nvgpu_safe_cast_u64_to_u32(x >> 32) & ~(u32)0;
ret = nvgpu_posix_hweight32(lo);
ret += nvgpu_posix_hweight32(hi);
return ret;
}