diff mbox series

[09/10] include/exec: fix assert in size_memop

Message ID 20250319182255.3096731-10-alex.bennee@linaro.org
State New
Headers show
Series gdbstub: conversion to runtime endianess helpers | expand

Commit Message

Alex Bennée March 19, 2025, 6:22 p.m. UTC
We can handle larger sized memops now, expand the range of the assert.

Fixes: 4b473e0c60 (tcg: Expand MO_SIZE to 3 bits)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/exec/memop.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Akihiko Odaki March 20, 2025, 6:29 a.m. UTC | #1
Updating the email address of Juan Quintela according to .mailmap.

On 2025/03/20 3:22, Alex Bennée wrote:
> We can handle larger sized memops now, expand the range of the assert.
> 
> Fixes: 4b473e0c60 (tcg: Expand MO_SIZE to 3 bits)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   include/exec/memop.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/exec/memop.h b/include/exec/memop.h
> index 407a47d82c..faed3ff902 100644
> --- a/include/exec/memop.h
> +++ b/include/exec/memop.h
> @@ -162,8 +162,8 @@ static inline unsigned memop_size(MemOp op)
>   static inline MemOp size_memop(unsigned size)
>   {
>   #ifdef CONFIG_DEBUG_TCG
> -    /* Power of 2 up to 8.  */
> -    assert((size & (size - 1)) == 0 && size >= 1 && size <= 8);
> +    /* Power of 2 up to 128.  */
> +    assert((size & (size - 1)) == 0 && size >= 1 && size <= 128);

This is the minimal change to fix, but perhaps it may be also nice to 
change it to use MO_SIZE.

Regards,
Akihiko Odaki

>   #endif
>       return (MemOp)ctz32(size);
>   }
Philippe Mathieu-Daudé March 20, 2025, 7:30 a.m. UTC | #2
On 20/3/25 07:29, Akihiko Odaki wrote:
> Updating the email address of Juan Quintela according to .mailmap.
> 
> On 2025/03/20 3:22, Alex Bennée wrote:
>> We can handle larger sized memops now, expand the range of the assert.
>>
>> Fixes: 4b473e0c60 (tcg: Expand MO_SIZE to 3 bits)
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   include/exec/memop.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/exec/memop.h b/include/exec/memop.h
>> index 407a47d82c..faed3ff902 100644
>> --- a/include/exec/memop.h
>> +++ b/include/exec/memop.h
>> @@ -162,8 +162,8 @@ static inline unsigned memop_size(MemOp op)
>>   static inline MemOp size_memop(unsigned size)
>>   {
>>   #ifdef CONFIG_DEBUG_TCG
>> -    /* Power of 2 up to 8.  */
>> -    assert((size & (size - 1)) == 0 && size >= 1 && size <= 8);
>> +    /* Power of 2 up to 128.  */
>> +    assert((size & (size - 1)) == 0 && size >= 1 && size <= 128);
> 
> This is the minimal change to fix, but perhaps it may be also nice to 
> change it to use MO_SIZE.

I concur.

       ... && size >= 1 && size <= (1 << MO_SIZE));

> Regards,
> Akihiko Odaki
> 
>>   #endif
>>       return (MemOp)ctz32(size);
>>   }
>
diff mbox series

Patch

diff --git a/include/exec/memop.h b/include/exec/memop.h
index 407a47d82c..faed3ff902 100644
--- a/include/exec/memop.h
+++ b/include/exec/memop.h
@@ -162,8 +162,8 @@  static inline unsigned memop_size(MemOp op)
 static inline MemOp size_memop(unsigned size)
 {
 #ifdef CONFIG_DEBUG_TCG
-    /* Power of 2 up to 8.  */
-    assert((size & (size - 1)) == 0 && size >= 1 && size <= 8);
+    /* Power of 2 up to 128.  */
+    assert((size & (size - 1)) == 0 && size >= 1 && size <= 128);
 #endif
     return (MemOp)ctz32(size);
 }