[PATCH] target/avr: Fix compiler errors (-Werror=enum-conversion)

Stefan Weil posted 1 patch 2 years, 10 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210706180936.249912-1-sw@weilnetz.de
target/avr/translate.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] target/avr: Fix compiler errors (-Werror=enum-conversion)
Posted by Stefan Weil 2 years, 10 months ago
../target/avr/translate.c: In function ‘gen_jmp_ez’:
../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
 1012 |     ctx->base.is_jmp = DISAS_LOOKUP;
      |                      ^

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

-Werror=enum-conversion is not enabled by -Wall, but by -Weverything
with clang for example.

As other targets use similar define statements, I think that's a simple fix.

Regards,
Stefan


 target/avr/translate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/target/avr/translate.c b/target/avr/translate.c
index c06ce45bc7..fcc839ac36 100644
--- a/target/avr/translate.c
+++ b/target/avr/translate.c
@@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8] = {
 };
 #define REG(x) (cpu_r[x])
 
-enum {
-    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main loop.  */
-    DISAS_LOOKUP = DISAS_TARGET_1,  /* We have a variable condition exit.  */
-    DISAS_CHAIN  = DISAS_TARGET_2,  /* We have a single condition exit.  */
-};
+#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main loop.  */
+#define DISAS_LOOKUP DISAS_TARGET_1  /* We have a variable condition exit.  */
+#define DISAS_CHAIN  DISAS_TARGET_2  /* We have a single condition exit.  */
 
 typedef struct DisasContext DisasContext;
 
-- 
2.30.2


Re: [PATCH] target/avr: Fix compiler errors (-Werror=enum-conversion)
Posted by Laurent Vivier 2 years, 7 months ago
Le 06/07/2021 à 20:09, Stefan Weil a écrit :
> ../target/avr/translate.c: In function ‘gen_jmp_ez’:
> ../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
>  1012 |     ctx->base.is_jmp = DISAS_LOOKUP;
>       |                      ^
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> 
> -Werror=enum-conversion is not enabled by -Wall, but by -Weverything
> with clang for example.
> 
> As other targets use similar define statements, I think that's a simple fix.
> 
> Regards,
> Stefan
> 
> 
>  target/avr/translate.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/target/avr/translate.c b/target/avr/translate.c
> index c06ce45bc7..fcc839ac36 100644
> --- a/target/avr/translate.c
> +++ b/target/avr/translate.c
> @@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8] = {
>  };
>  #define REG(x) (cpu_r[x])
>  
> -enum {
> -    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main loop.  */
> -    DISAS_LOOKUP = DISAS_TARGET_1,  /* We have a variable condition exit.  */
> -    DISAS_CHAIN  = DISAS_TARGET_2,  /* We have a single condition exit.  */
> -};
> +#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main loop.  */
> +#define DISAS_LOOKUP DISAS_TARGET_1  /* We have a variable condition exit.  */
> +#define DISAS_CHAIN  DISAS_TARGET_2  /* We have a single condition exit.  */
>  
>  typedef struct DisasContext DisasContext;
>  
> 

Applied to my trivial-patches branch.

Thanks,
Laurent

Re: [PATCH] target/avr: Fix compiler errors (-Werror=enum-conversion)
Posted by Michael Rolnik 2 years, 10 months ago
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>

On Tue, Jul 6, 2021 at 9:09 PM Stefan Weil <sw@weilnetz.de> wrote:

> ../target/avr/translate.c: In function ‘gen_jmp_ez’:
> ../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum
> <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
>  1012 |     ctx->base.is_jmp = DISAS_LOOKUP;
>       |                      ^
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> -Werror=enum-conversion is not enabled by -Wall, but by -Weverything
> with clang for example.
>
> As other targets use similar define statements, I think that's a simple
> fix.
>
> Regards,
> Stefan
>
>
>  target/avr/translate.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/target/avr/translate.c b/target/avr/translate.c
> index c06ce45bc7..fcc839ac36 100644
> --- a/target/avr/translate.c
> +++ b/target/avr/translate.c
> @@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8]
> = {
>  };
>  #define REG(x) (cpu_r[x])
>
> -enum {
> -    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main
> loop.  */
> -    DISAS_LOOKUP = DISAS_TARGET_1,  /* We have a variable condition
> exit.  */
> -    DISAS_CHAIN  = DISAS_TARGET_2,  /* We have a single condition exit.
> */
> -};
> +#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main
> loop.  */
> +#define DISAS_LOOKUP DISAS_TARGET_1  /* We have a variable condition
> exit.  */
> +#define DISAS_CHAIN  DISAS_TARGET_2  /* We have a single condition exit.
> */
>
>  typedef struct DisasContext DisasContext;
>
> --
> 2.30.2
>
>

-- 
Best Regards,
Michael Rolnik