[libdrm,1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping
diff mbox series

Message ID 20180814095657.10914-1-michel@daenzer.net
State New
Headers show
Series
  • [libdrm,1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping
Related show

Commit Message

Michel Dänzer Aug. 14, 2018, 9:56 a.m. UTC
From: Michel Dänzer <michel.daenzer@amd.com>

The compiler points out that an int doesn't work as intended if
dev->bo_handles.max_key > INT_MAX:

../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’:
../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  for (i = 0; i < dev->bo_handles.max_key; i++) {
                ^
../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  if (i < dev->bo_handles.max_key) {
        ^

Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping
                     (v2)")
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 amdgpu/amdgpu_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian König Aug. 14, 2018, 10 a.m. UTC | #1
Am 14.08.2018 um 11:56 schrieb Michel Dänzer:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> The compiler points out that an int doesn't work as intended if
> dev->bo_handles.max_key > INT_MAX:
>
> ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’:
> ../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
>    for (i = 0; i < dev->bo_handles.max_key; i++) {
>                  ^
> ../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
>    if (i < dev->bo_handles.max_key) {
>          ^
>
> Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping
>                       (v2)")
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com> for the series.

> ---
>   amdgpu/amdgpu_bo.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index b790e9be..86d1c143 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -535,7 +535,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
>   				  amdgpu_bo_handle *buf_handle,
>   				  uint64_t *offset_in_bo)
>   {
> -	int i;
> +	uint32_t i;
>   	struct amdgpu_bo *bo;
>   
>   	if (cpu == NULL || size == 0)

Patch
diff mbox series

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index b790e9be..86d1c143 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -535,7 +535,7 @@  int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
 				  amdgpu_bo_handle *buf_handle,
 				  uint64_t *offset_in_bo)
 {
-	int i;
+	uint32_t i;
 	struct amdgpu_bo *bo;
 
 	if (cpu == NULL || size == 0)