diff mbox

[libdrm,4/7] tests/amdgpu: fix bad sign comparisons

Message ID 20180126113244.26946-4-eric.engestrom@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Engestrom Jan. 26, 2018, 11:32 a.m. UTC
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
---
 tests/amdgpu/cs_tests.c      |  2 +-
 tests/amdgpu/uvd_enc_tests.c | 10 +++++-----
 tests/amdgpu/vce_tests.c     | 10 +++++-----
 tests/amdgpu/vcn_tests.c     |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

Comments

Christian König Jan. 26, 2018, 11:38 a.m. UTC | #1
Am 26.01.2018 um 12:32 schrieb Eric Engestrom:
> Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
> ---
>   tests/amdgpu/cs_tests.c      |  2 +-
>   tests/amdgpu/uvd_enc_tests.c | 10 +++++-----
>   tests/amdgpu/vce_tests.c     | 10 +++++-----
>   tests/amdgpu/vcn_tests.c     |  4 ++--
>   4 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
> index a5361cd59457d039dea9..40700f53d35f3340b895 100644
> --- a/tests/amdgpu/cs_tests.c
> +++ b/tests/amdgpu/cs_tests.c
> @@ -396,7 +396,7 @@ static void amdgpu_cs_uvd_decode(void)
>   	CU_ASSERT_EQUAL(r, 0);
>   
>   	/* TODO: use a real CRC32 */
> -	for (i = 0, sum = 0; i < dt_size; ++i)
> +	for (uint64_t i = 0, sum = 0; i < dt_size; ++i)

Please keep the define local to the function, even worse this seems to 
shadow a local defined i.

Christian.

>   		sum += ptr[i];
>   	CU_ASSERT_EQUAL(sum, SUM_DECODE);
>   
> diff --git a/tests/amdgpu/uvd_enc_tests.c b/tests/amdgpu/uvd_enc_tests.c
> index 0377c1a5d7e1b789d782..c1b840e3e56d83d0a3af 100644
> --- a/tests/amdgpu/uvd_enc_tests.c
> +++ b/tests/amdgpu/uvd_enc_tests.c
> @@ -261,7 +261,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
>   	uint64_t sum;
>   	uint32_t s = 175602;
>   	uint32_t *ptr, size;
> -	int j, r;
> +	int r;
>   
>   	r = amdgpu_bo_cpu_map(enc->fb.handle, (void **)&enc->fb.ptr);
>   	CU_ASSERT_EQUAL(r, 0);
> @@ -271,7 +271,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
>   	CU_ASSERT_EQUAL(r, 0);
>   	r = amdgpu_bo_cpu_map(enc->bs.handle, (void **)&enc->bs.ptr);
>   	CU_ASSERT_EQUAL(r, 0);
> -	for (j = 0, sum = 0; j < size; ++j)
> +	for (uint32_t j = 0, sum = 0; j < size; ++j)
>   		sum += enc->bs.ptr[j];
>   	CU_ASSERT_EQUAL(sum, s);
>   	r = amdgpu_bo_cpu_unmap(enc->bs.handle);
> @@ -331,7 +331,7 @@ static void amdgpu_cs_uvd_enc_session_init(void)
>   
>   static void amdgpu_cs_uvd_enc_encode(void)
>   {
> -	int len, r, i;
> +	int len, r;
>   	uint64_t luma_offset, chroma_offset;
>   	uint32_t vbuf_size, bs_size = 0x003f4800, cpb_size;
>   	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
> @@ -354,11 +354,11 @@ static void amdgpu_cs_uvd_enc_encode(void)
>   	CU_ASSERT_EQUAL(r, 0);
>   
>   	memset(enc.vbuf.ptr, 0, vbuf_size);
> -	for (i = 0; i < enc.height; ++i) {
> +	for (unsigned i = 0; i < enc.height; ++i) {
>   		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
>   		enc.vbuf.ptr += ALIGN(enc.width, align);
>   	}
> -	for (i = 0; i < enc.height / 2; ++i) {
> +	for (unsigned i = 0; i < enc.height / 2; ++i) {
>   		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
>   		enc.vbuf.ptr += ALIGN(enc.width, align);
>   	}
> diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
> index 75821bbb1e6c92e91fe7..6da6511793a1cf0ab488 100644
> --- a/tests/amdgpu/vce_tests.c
> +++ b/tests/amdgpu/vce_tests.c
> @@ -425,8 +425,8 @@ static void check_result(struct amdgpu_vce_encode *enc)
>   {
>   	uint64_t sum;
>   	uint32_t s[2] = {180325, 15946};
> -	uint32_t *ptr, size;
> -	int i, j, r;
> +	uint32_t *ptr, i, j, size;
> +	int r;
>   
>   	for (i = 0; i < 2; ++i) {
>   		r = amdgpu_bo_cpu_map(enc->fb[i].handle, (void **)&enc->fb[i].ptr);
> @@ -449,7 +449,7 @@ static void amdgpu_cs_vce_encode(void)
>   {
>   	uint32_t vbuf_size, bs_size = 0x154000, cpb_size;
>   	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
> -	int i, r;
> +	int r;
>   
>   	vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5;
>   	cpb_size = vbuf_size * 10;
> @@ -472,11 +472,11 @@ static void amdgpu_cs_vce_encode(void)
>   	CU_ASSERT_EQUAL(r, 0);
>   
>   	memset(enc.vbuf.ptr, 0, vbuf_size);
> -	for (i = 0; i < enc.height; ++i) {
> +	for (unsigned i = 0; i < enc.height; ++i) {
>   		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
>   		enc.vbuf.ptr += ALIGN(enc.width, align);
>   	}
> -	for (i = 0; i < enc.height / 2; ++i) {
> +	for (unsigned i = 0; i < enc.height / 2; ++i) {
>   		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
>   		enc.vbuf.ptr += ALIGN(enc.width, align);
>   	}
> diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c
> index 2eb8c4347be094a70958..b228db609f0e0c0fefdd 100644
> --- a/tests/amdgpu/vcn_tests.c
> +++ b/tests/amdgpu/vcn_tests.c
> @@ -239,7 +239,7 @@ static void free_resource(struct amdgpu_vcn_bo *vcn_bo)
>   	memset(vcn_bo, 0, sizeof(*vcn_bo));
>   }
>   
> -static void vcn_dec_cmd(uint64_t addr, unsigned cmd, int *idx)
> +static void vcn_dec_cmd(uint64_t addr, unsigned cmd, unsigned *idx)
>   {
>   	ib_cpu[(*idx)++] = 0x81C4;
>   	ib_cpu[(*idx)++] = addr;
> @@ -286,7 +286,7 @@ static void amdgpu_cs_vcn_dec_decode(void)
>   	const unsigned dpb_size = 15923584, dt_size = 737280;
>   	uint64_t msg_addr, fb_addr, bs_addr, dpb_addr, ctx_addr, dt_addr, it_addr, sum;
>   	struct amdgpu_vcn_bo dec_buf;
> -	int size, len, i, r;
> +	unsigned size, len, i, r;
>   	uint8_t *dec;
>   
>   	size = 4*1024; /* msg */
Eric Engestrom Jan. 26, 2018, 5:15 p.m. UTC | #2
On Friday, 2018-01-26 12:38:35 +0100, Christian König wrote:
> Am 26.01.2018 um 12:32 schrieb Eric Engestrom:
> > Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
> > ---
> >   tests/amdgpu/cs_tests.c      |  2 +-
> >   tests/amdgpu/uvd_enc_tests.c | 10 +++++-----
> >   tests/amdgpu/vce_tests.c     | 10 +++++-----
> >   tests/amdgpu/vcn_tests.c     |  4 ++--
> >   4 files changed, 13 insertions(+), 13 deletions(-)
> > 
> > diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
> > index a5361cd59457d039dea9..40700f53d35f3340b895 100644
> > --- a/tests/amdgpu/cs_tests.c
> > +++ b/tests/amdgpu/cs_tests.c
> > @@ -396,7 +396,7 @@ static void amdgpu_cs_uvd_decode(void)
> >   	CU_ASSERT_EQUAL(r, 0);
> >   	/* TODO: use a real CRC32 */
> > -	for (i = 0, sum = 0; i < dt_size; ++i)
> > +	for (uint64_t i = 0, sum = 0; i < dt_size; ++i)
> 
> Please keep the define local to the function,

I assume this applies to all the hunks in this patch, right?
I'll send a v2 later (ie. next week).

> even worse this seems to shadow a local defined i.

It does shadow the function-wide `i`, because it's a different kind of
index. I guess really it should have a different name, but I don't know
enought about what this is all doing to think of a good name; any ideas?

> 
> Christian.
> 
> >   		sum += ptr[i];
> >   	CU_ASSERT_EQUAL(sum, SUM_DECODE);
> > diff --git a/tests/amdgpu/uvd_enc_tests.c b/tests/amdgpu/uvd_enc_tests.c
> > index 0377c1a5d7e1b789d782..c1b840e3e56d83d0a3af 100644
> > --- a/tests/amdgpu/uvd_enc_tests.c
> > +++ b/tests/amdgpu/uvd_enc_tests.c
> > @@ -261,7 +261,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
> >   	uint64_t sum;
> >   	uint32_t s = 175602;
> >   	uint32_t *ptr, size;
> > -	int j, r;
> > +	int r;
> >   	r = amdgpu_bo_cpu_map(enc->fb.handle, (void **)&enc->fb.ptr);
> >   	CU_ASSERT_EQUAL(r, 0);
> > @@ -271,7 +271,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
> >   	CU_ASSERT_EQUAL(r, 0);
> >   	r = amdgpu_bo_cpu_map(enc->bs.handle, (void **)&enc->bs.ptr);
> >   	CU_ASSERT_EQUAL(r, 0);
> > -	for (j = 0, sum = 0; j < size; ++j)
> > +	for (uint32_t j = 0, sum = 0; j < size; ++j)
> >   		sum += enc->bs.ptr[j];
> >   	CU_ASSERT_EQUAL(sum, s);
> >   	r = amdgpu_bo_cpu_unmap(enc->bs.handle);
> > @@ -331,7 +331,7 @@ static void amdgpu_cs_uvd_enc_session_init(void)
> >   static void amdgpu_cs_uvd_enc_encode(void)
> >   {
> > -	int len, r, i;
> > +	int len, r;
> >   	uint64_t luma_offset, chroma_offset;
> >   	uint32_t vbuf_size, bs_size = 0x003f4800, cpb_size;
> >   	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
> > @@ -354,11 +354,11 @@ static void amdgpu_cs_uvd_enc_encode(void)
> >   	CU_ASSERT_EQUAL(r, 0);
> >   	memset(enc.vbuf.ptr, 0, vbuf_size);
> > -	for (i = 0; i < enc.height; ++i) {
> > +	for (unsigned i = 0; i < enc.height; ++i) {
> >   		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
> >   		enc.vbuf.ptr += ALIGN(enc.width, align);
> >   	}
> > -	for (i = 0; i < enc.height / 2; ++i) {
> > +	for (unsigned i = 0; i < enc.height / 2; ++i) {
> >   		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
> >   		enc.vbuf.ptr += ALIGN(enc.width, align);
> >   	}
> > diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
> > index 75821bbb1e6c92e91fe7..6da6511793a1cf0ab488 100644
> > --- a/tests/amdgpu/vce_tests.c
> > +++ b/tests/amdgpu/vce_tests.c
> > @@ -425,8 +425,8 @@ static void check_result(struct amdgpu_vce_encode *enc)
> >   {
> >   	uint64_t sum;
> >   	uint32_t s[2] = {180325, 15946};
> > -	uint32_t *ptr, size;
> > -	int i, j, r;
> > +	uint32_t *ptr, i, j, size;
> > +	int r;
> >   	for (i = 0; i < 2; ++i) {
> >   		r = amdgpu_bo_cpu_map(enc->fb[i].handle, (void **)&enc->fb[i].ptr);
> > @@ -449,7 +449,7 @@ static void amdgpu_cs_vce_encode(void)
> >   {
> >   	uint32_t vbuf_size, bs_size = 0x154000, cpb_size;
> >   	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
> > -	int i, r;
> > +	int r;
> >   	vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5;
> >   	cpb_size = vbuf_size * 10;
> > @@ -472,11 +472,11 @@ static void amdgpu_cs_vce_encode(void)
> >   	CU_ASSERT_EQUAL(r, 0);
> >   	memset(enc.vbuf.ptr, 0, vbuf_size);
> > -	for (i = 0; i < enc.height; ++i) {
> > +	for (unsigned i = 0; i < enc.height; ++i) {
> >   		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
> >   		enc.vbuf.ptr += ALIGN(enc.width, align);
> >   	}
> > -	for (i = 0; i < enc.height / 2; ++i) {
> > +	for (unsigned i = 0; i < enc.height / 2; ++i) {
> >   		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
> >   		enc.vbuf.ptr += ALIGN(enc.width, align);
> >   	}
> > diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c
> > index 2eb8c4347be094a70958..b228db609f0e0c0fefdd 100644
> > --- a/tests/amdgpu/vcn_tests.c
> > +++ b/tests/amdgpu/vcn_tests.c
> > @@ -239,7 +239,7 @@ static void free_resource(struct amdgpu_vcn_bo *vcn_bo)
> >   	memset(vcn_bo, 0, sizeof(*vcn_bo));
> >   }
> > -static void vcn_dec_cmd(uint64_t addr, unsigned cmd, int *idx)
> > +static void vcn_dec_cmd(uint64_t addr, unsigned cmd, unsigned *idx)
> >   {
> >   	ib_cpu[(*idx)++] = 0x81C4;
> >   	ib_cpu[(*idx)++] = addr;
> > @@ -286,7 +286,7 @@ static void amdgpu_cs_vcn_dec_decode(void)
> >   	const unsigned dpb_size = 15923584, dt_size = 737280;
> >   	uint64_t msg_addr, fb_addr, bs_addr, dpb_addr, ctx_addr, dt_addr, it_addr, sum;
> >   	struct amdgpu_vcn_bo dec_buf;
> > -	int size, len, i, r;
> > +	unsigned size, len, i, r;
> >   	uint8_t *dec;
> >   	size = 4*1024; /* msg */
>
Christian König Jan. 26, 2018, 5:17 p.m. UTC | #3
Am 26.01.2018 um 18:15 schrieb Eric Engestrom:
> On Friday, 2018-01-26 12:38:35 +0100, Christian König wrote:
>> Am 26.01.2018 um 12:32 schrieb Eric Engestrom:
>>> Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
>>> ---
>>>    tests/amdgpu/cs_tests.c      |  2 +-
>>>    tests/amdgpu/uvd_enc_tests.c | 10 +++++-----
>>>    tests/amdgpu/vce_tests.c     | 10 +++++-----
>>>    tests/amdgpu/vcn_tests.c     |  4 ++--
>>>    4 files changed, 13 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
>>> index a5361cd59457d039dea9..40700f53d35f3340b895 100644
>>> --- a/tests/amdgpu/cs_tests.c
>>> +++ b/tests/amdgpu/cs_tests.c
>>> @@ -396,7 +396,7 @@ static void amdgpu_cs_uvd_decode(void)
>>>    	CU_ASSERT_EQUAL(r, 0);
>>>    	/* TODO: use a real CRC32 */
>>> -	for (i = 0, sum = 0; i < dt_size; ++i)
>>> +	for (uint64_t i = 0, sum = 0; i < dt_size; ++i)
>> Please keep the define local to the function,
> I assume this applies to all the hunks in this patch, right?

Yeah, in general we try to follow kernel coding style rules with the 
libdrm amdgpu stuff.

> I'll send a v2 later (ie. next week).
>
>> even worse this seems to shadow a local defined i.
> It does shadow the function-wide `i`, because it's a different kind of
> index. I guess really it should have a different name, but I don't know
> enought about what this is all doing to think of a good name; any ideas?

Just make the function wide i uint64_t, that should work and nothing of 
that code is performance critical.

Christian.

>
>> Christian.
>>
>>>    		sum += ptr[i];
>>>    	CU_ASSERT_EQUAL(sum, SUM_DECODE);
>>> diff --git a/tests/amdgpu/uvd_enc_tests.c b/tests/amdgpu/uvd_enc_tests.c
>>> index 0377c1a5d7e1b789d782..c1b840e3e56d83d0a3af 100644
>>> --- a/tests/amdgpu/uvd_enc_tests.c
>>> +++ b/tests/amdgpu/uvd_enc_tests.c
>>> @@ -261,7 +261,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
>>>    	uint64_t sum;
>>>    	uint32_t s = 175602;
>>>    	uint32_t *ptr, size;
>>> -	int j, r;
>>> +	int r;
>>>    	r = amdgpu_bo_cpu_map(enc->fb.handle, (void **)&enc->fb.ptr);
>>>    	CU_ASSERT_EQUAL(r, 0);
>>> @@ -271,7 +271,7 @@ static void check_result(struct amdgpu_uvd_enc *enc)
>>>    	CU_ASSERT_EQUAL(r, 0);
>>>    	r = amdgpu_bo_cpu_map(enc->bs.handle, (void **)&enc->bs.ptr);
>>>    	CU_ASSERT_EQUAL(r, 0);
>>> -	for (j = 0, sum = 0; j < size; ++j)
>>> +	for (uint32_t j = 0, sum = 0; j < size; ++j)
>>>    		sum += enc->bs.ptr[j];
>>>    	CU_ASSERT_EQUAL(sum, s);
>>>    	r = amdgpu_bo_cpu_unmap(enc->bs.handle);
>>> @@ -331,7 +331,7 @@ static void amdgpu_cs_uvd_enc_session_init(void)
>>>    static void amdgpu_cs_uvd_enc_encode(void)
>>>    {
>>> -	int len, r, i;
>>> +	int len, r;
>>>    	uint64_t luma_offset, chroma_offset;
>>>    	uint32_t vbuf_size, bs_size = 0x003f4800, cpb_size;
>>>    	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
>>> @@ -354,11 +354,11 @@ static void amdgpu_cs_uvd_enc_encode(void)
>>>    	CU_ASSERT_EQUAL(r, 0);
>>>    	memset(enc.vbuf.ptr, 0, vbuf_size);
>>> -	for (i = 0; i < enc.height; ++i) {
>>> +	for (unsigned i = 0; i < enc.height; ++i) {
>>>    		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
>>>    		enc.vbuf.ptr += ALIGN(enc.width, align);
>>>    	}
>>> -	for (i = 0; i < enc.height / 2; ++i) {
>>> +	for (unsigned i = 0; i < enc.height / 2; ++i) {
>>>    		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
>>>    		enc.vbuf.ptr += ALIGN(enc.width, align);
>>>    	}
>>> diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
>>> index 75821bbb1e6c92e91fe7..6da6511793a1cf0ab488 100644
>>> --- a/tests/amdgpu/vce_tests.c
>>> +++ b/tests/amdgpu/vce_tests.c
>>> @@ -425,8 +425,8 @@ static void check_result(struct amdgpu_vce_encode *enc)
>>>    {
>>>    	uint64_t sum;
>>>    	uint32_t s[2] = {180325, 15946};
>>> -	uint32_t *ptr, size;
>>> -	int i, j, r;
>>> +	uint32_t *ptr, i, j, size;
>>> +	int r;
>>>    	for (i = 0; i < 2; ++i) {
>>>    		r = amdgpu_bo_cpu_map(enc->fb[i].handle, (void **)&enc->fb[i].ptr);
>>> @@ -449,7 +449,7 @@ static void amdgpu_cs_vce_encode(void)
>>>    {
>>>    	uint32_t vbuf_size, bs_size = 0x154000, cpb_size;
>>>    	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
>>> -	int i, r;
>>> +	int r;
>>>    	vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5;
>>>    	cpb_size = vbuf_size * 10;
>>> @@ -472,11 +472,11 @@ static void amdgpu_cs_vce_encode(void)
>>>    	CU_ASSERT_EQUAL(r, 0);
>>>    	memset(enc.vbuf.ptr, 0, vbuf_size);
>>> -	for (i = 0; i < enc.height; ++i) {
>>> +	for (unsigned i = 0; i < enc.height; ++i) {
>>>    		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
>>>    		enc.vbuf.ptr += ALIGN(enc.width, align);
>>>    	}
>>> -	for (i = 0; i < enc.height / 2; ++i) {
>>> +	for (unsigned i = 0; i < enc.height / 2; ++i) {
>>>    		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
>>>    		enc.vbuf.ptr += ALIGN(enc.width, align);
>>>    	}
>>> diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c
>>> index 2eb8c4347be094a70958..b228db609f0e0c0fefdd 100644
>>> --- a/tests/amdgpu/vcn_tests.c
>>> +++ b/tests/amdgpu/vcn_tests.c
>>> @@ -239,7 +239,7 @@ static void free_resource(struct amdgpu_vcn_bo *vcn_bo)
>>>    	memset(vcn_bo, 0, sizeof(*vcn_bo));
>>>    }
>>> -static void vcn_dec_cmd(uint64_t addr, unsigned cmd, int *idx)
>>> +static void vcn_dec_cmd(uint64_t addr, unsigned cmd, unsigned *idx)
>>>    {
>>>    	ib_cpu[(*idx)++] = 0x81C4;
>>>    	ib_cpu[(*idx)++] = addr;
>>> @@ -286,7 +286,7 @@ static void amdgpu_cs_vcn_dec_decode(void)
>>>    	const unsigned dpb_size = 15923584, dt_size = 737280;
>>>    	uint64_t msg_addr, fb_addr, bs_addr, dpb_addr, ctx_addr, dt_addr, it_addr, sum;
>>>    	struct amdgpu_vcn_bo dec_buf;
>>> -	int size, len, i, r;
>>> +	unsigned size, len, i, r;
>>>    	uint8_t *dec;
>>>    	size = 4*1024; /* msg */
diff mbox

Patch

diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
index a5361cd59457d039dea9..40700f53d35f3340b895 100644
--- a/tests/amdgpu/cs_tests.c
+++ b/tests/amdgpu/cs_tests.c
@@ -396,7 +396,7 @@  static void amdgpu_cs_uvd_decode(void)
 	CU_ASSERT_EQUAL(r, 0);
 
 	/* TODO: use a real CRC32 */
-	for (i = 0, sum = 0; i < dt_size; ++i)
+	for (uint64_t i = 0, sum = 0; i < dt_size; ++i)
 		sum += ptr[i];
 	CU_ASSERT_EQUAL(sum, SUM_DECODE);
 
diff --git a/tests/amdgpu/uvd_enc_tests.c b/tests/amdgpu/uvd_enc_tests.c
index 0377c1a5d7e1b789d782..c1b840e3e56d83d0a3af 100644
--- a/tests/amdgpu/uvd_enc_tests.c
+++ b/tests/amdgpu/uvd_enc_tests.c
@@ -261,7 +261,7 @@  static void check_result(struct amdgpu_uvd_enc *enc)
 	uint64_t sum;
 	uint32_t s = 175602;
 	uint32_t *ptr, size;
-	int j, r;
+	int r;
 
 	r = amdgpu_bo_cpu_map(enc->fb.handle, (void **)&enc->fb.ptr);
 	CU_ASSERT_EQUAL(r, 0);
@@ -271,7 +271,7 @@  static void check_result(struct amdgpu_uvd_enc *enc)
 	CU_ASSERT_EQUAL(r, 0);
 	r = amdgpu_bo_cpu_map(enc->bs.handle, (void **)&enc->bs.ptr);
 	CU_ASSERT_EQUAL(r, 0);
-	for (j = 0, sum = 0; j < size; ++j)
+	for (uint32_t j = 0, sum = 0; j < size; ++j)
 		sum += enc->bs.ptr[j];
 	CU_ASSERT_EQUAL(sum, s);
 	r = amdgpu_bo_cpu_unmap(enc->bs.handle);
@@ -331,7 +331,7 @@  static void amdgpu_cs_uvd_enc_session_init(void)
 
 static void amdgpu_cs_uvd_enc_encode(void)
 {
-	int len, r, i;
+	int len, r;
 	uint64_t luma_offset, chroma_offset;
 	uint32_t vbuf_size, bs_size = 0x003f4800, cpb_size;
 	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
@@ -354,11 +354,11 @@  static void amdgpu_cs_uvd_enc_encode(void)
 	CU_ASSERT_EQUAL(r, 0);
 
 	memset(enc.vbuf.ptr, 0, vbuf_size);
-	for (i = 0; i < enc.height; ++i) {
+	for (unsigned i = 0; i < enc.height; ++i) {
 		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
 		enc.vbuf.ptr += ALIGN(enc.width, align);
 	}
-	for (i = 0; i < enc.height / 2; ++i) {
+	for (unsigned i = 0; i < enc.height / 2; ++i) {
 		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
 		enc.vbuf.ptr += ALIGN(enc.width, align);
 	}
diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
index 75821bbb1e6c92e91fe7..6da6511793a1cf0ab488 100644
--- a/tests/amdgpu/vce_tests.c
+++ b/tests/amdgpu/vce_tests.c
@@ -425,8 +425,8 @@  static void check_result(struct amdgpu_vce_encode *enc)
 {
 	uint64_t sum;
 	uint32_t s[2] = {180325, 15946};
-	uint32_t *ptr, size;
-	int i, j, r;
+	uint32_t *ptr, i, j, size;
+	int r;
 
 	for (i = 0; i < 2; ++i) {
 		r = amdgpu_bo_cpu_map(enc->fb[i].handle, (void **)&enc->fb[i].ptr);
@@ -449,7 +449,7 @@  static void amdgpu_cs_vce_encode(void)
 {
 	uint32_t vbuf_size, bs_size = 0x154000, cpb_size;
 	unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16;
-	int i, r;
+	int r;
 
 	vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5;
 	cpb_size = vbuf_size * 10;
@@ -472,11 +472,11 @@  static void amdgpu_cs_vce_encode(void)
 	CU_ASSERT_EQUAL(r, 0);
 
 	memset(enc.vbuf.ptr, 0, vbuf_size);
-	for (i = 0; i < enc.height; ++i) {
+	for (unsigned i = 0; i < enc.height; ++i) {
 		memcpy(enc.vbuf.ptr, (frame + i * enc.width), enc.width);
 		enc.vbuf.ptr += ALIGN(enc.width, align);
 	}
-	for (i = 0; i < enc.height / 2; ++i) {
+	for (unsigned i = 0; i < enc.height / 2; ++i) {
 		memcpy(enc.vbuf.ptr, ((frame + enc.height * enc.width) + i * enc.width), enc.width);
 		enc.vbuf.ptr += ALIGN(enc.width, align);
 	}
diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c
index 2eb8c4347be094a70958..b228db609f0e0c0fefdd 100644
--- a/tests/amdgpu/vcn_tests.c
+++ b/tests/amdgpu/vcn_tests.c
@@ -239,7 +239,7 @@  static void free_resource(struct amdgpu_vcn_bo *vcn_bo)
 	memset(vcn_bo, 0, sizeof(*vcn_bo));
 }
 
-static void vcn_dec_cmd(uint64_t addr, unsigned cmd, int *idx)
+static void vcn_dec_cmd(uint64_t addr, unsigned cmd, unsigned *idx)
 {
 	ib_cpu[(*idx)++] = 0x81C4;
 	ib_cpu[(*idx)++] = addr;
@@ -286,7 +286,7 @@  static void amdgpu_cs_vcn_dec_decode(void)
 	const unsigned dpb_size = 15923584, dt_size = 737280;
 	uint64_t msg_addr, fb_addr, bs_addr, dpb_addr, ctx_addr, dt_addr, it_addr, sum;
 	struct amdgpu_vcn_bo dec_buf;
-	int size, len, i, r;
+	unsigned size, len, i, r;
 	uint8_t *dec;
 
 	size = 4*1024; /* msg */