gpu: nvgpu: Fix for MISRA 10.3, 10.4 violation

- Implicit conversion from essential type "signed 32-bit int" to
  "unsigned 64-bit int".

- Essential type of the left hand operand "32UL" (unsigned) is not
  the same as that of the right operand "1"(signed)

JIRA NVGPU-6055

Change-Id: I22b0e345b851b33faca0b09c42a57b80b9f4f620
Signed-off-by: Seeta Rama Raju <srajum@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2447254
(cherry picked from commit 1e035ad03ad19cf89f248b3b4e83f734aa646e8c)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2454502
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@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>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Seeta Rama Raju
2020-11-17 17:22:50 +05:30
committed by Alex Waterman
parent 722ee1cbc5
commit 471ea46f91

View File

@@ -52,9 +52,9 @@ static int user_sync_build_debug_name(struct nvgpu_channel *ch,
nvgpu_err(g, "strnadd failed!");
return -EINVAL;
}
capacity = nvgpu_safe_sub_u64(capacity, n);
capacity = nvgpu_safe_sub_u64(capacity, nvgpu_safe_cast_s32_to_u64(n));
/* nul byte */
capacity = nvgpu_safe_sub_u64(capacity, 1);
capacity = nvgpu_safe_sub_u64(capacity, 1UL);
(void)strncat(buf, "_user", capacity);
/* make sure it didn't get truncated */
@@ -80,7 +80,7 @@ nvgpu_channel_user_syncpt_create(struct nvgpu_channel *ch)
s->nvhost = g->nvhost;
err = user_sync_build_debug_name(ch, syncpt_name,
sizeof(syncpt_name) - 1);
sizeof(syncpt_name) - 1UL);
if (err < 0) {
goto err_free;
}