gpu: nvgpu: Fix Bad bit shift Coverity issues

Fixed following Coverity Defects:
ioctl_as.c : Bad bit shift operation
mc_tu104.c : Bad bit shift operation
vm.c : Bad bit shift operation
vm_remap.c : Bad bit shift operation

A new linux header file for ilog2 is created.
The files which used the old ilog2 function
have been changed to use the new nvgpu_ilog2
function.

CID 9847922
CID 9869507
CID 9859508
CID 10112314
CID 10127813
CID 10127899
CID 10128004

Signed-off-by: Jinesh Parakh <jparakh@nvidia.com>
Change-Id: Ia201eea7cc426c3d6581e1e5ae3b882dbab3b490
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2700994
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jinesh Parakh
2022-04-21 19:42:23 +05:30
committed by mobile promotions
parent 167e7b0256
commit 622fe70dab
16 changed files with 153 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -37,7 +37,7 @@ int test_ilog2(struct unit_module *m,
for (i = 0; i < BITS_PER_LONG; i++) {
test = 1UL << i;
ret = ilog2(test);
ret = nvgpu_ilog2(test);
if (ret != i) {
unit_return_fail(m,
"ilog2 failure %ld\n", test);
@@ -47,7 +47,7 @@ int test_ilog2(struct unit_module *m,
for (i = 1; i < (BITS_PER_LONG - 1); i++) {
test = 1UL << i;
test += 1;
ret = ilog2(test);
ret = nvgpu_ilog2(test);
if (ret != i) {
unit_return_fail(m,
"ilog2 failure %ld\n", test);