[29/40] sim/ppc: Fix indentation on generated code

Message ID 04f72f880579950f6196da72073a3698582fda0b.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Clang generates a warning if there is a block statement and another
adjacent statement with a misleading indent ("-Wmisleading-indentation").
On the default configuration, it causes a build failure
(unless "--disable-werror" is specified).

The cause of this warning, $(builddir)/sim/ppc/semantics.c is generated by
$(srcdir)/sim/ppc/igen.c and this commit fixes generating misleading
indentation by removing two spaces.
---
 sim/ppc/igen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 3:07 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> Clang generates a warning if there is a block statement and another
> adjacent statement with a misleading indent ("-Wmisleading-indentation").
> On the default configuration, it causes a build failure
> (unless "--disable-werror" is specified).
> 
> The cause of this warning, $(builddir)/sim/ppc/semantics.c is generated by
> $(srcdir)/sim/ppc/igen.c and this commit fixes generating misleading
> indentation by removing two spaces.
> ---
>  sim/ppc/igen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c
> index 27b48638276..786ea540d57 100644
> --- a/sim/ppc/igen.c
> +++ b/sim/ppc/igen.c
> @@ -233,7 +233,7 @@ gen_semantics_c(insn_table *table,
>      lf_printf(file, "  option_mpc860c0 = 0;\n");
>      lf_printf(file, "  if (tree_find_property(root, \"/options/mpc860c0\"))\n");
>      lf_printf(file, "    option_mpc860c0 = tree_find_integer_property(root, \"/options/mpc860c0\");\n");
> -    lf_printf(file, "    option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
> +    lf_printf(file, "  option_mpc860c0 *= 4;   /* convert word count to byte count */\n");

this maintains existing behavior, and logically it's the same, but i think we
should fix the intention of the code -- add braces so that the *4 only happens
inside the if statement.
-mike
  

Patch

diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c
index 27b48638276..786ea540d57 100644
--- a/sim/ppc/igen.c
+++ b/sim/ppc/igen.c
@@ -233,7 +233,7 @@  gen_semantics_c(insn_table *table,
     lf_printf(file, "  option_mpc860c0 = 0;\n");
     lf_printf(file, "  if (tree_find_property(root, \"/options/mpc860c0\"))\n");
     lf_printf(file, "    option_mpc860c0 = tree_find_integer_property(root, \"/options/mpc860c0\");\n");
-    lf_printf(file, "    option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
+    lf_printf(file, "  option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
     lf_printf(file, "}\n");
     lf_printf(file, "\n");
     if (generate_expanded_instructions)