diff mbox series

[5/6] inline: allocate statement after guards

Message ID 20220626130748.74163-6-lucvoo@kernel.org (mailing list archive)
State Mainlined, archived
Headers show
Series cleanup related to inlining of variadic functions | expand

Commit Message

Luc Van Oostenryck June 26, 2022, 1:07 p.m. UTC
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

In inline_function(), the statement that will correspond to the
inlined code is allocated in the function declaration but then
it's checked if the function can be allocated or not.

This is not much memory and the checks should succeed most of the time
but it's clearer if the statement is allocated after the checks.

So, move the allocation after the checks.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 inline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/inline.c b/inline.c
index a6f9252ab0ff..68f235c21945 100644
--- a/inline.c
+++ b/inline.c
@@ -516,7 +516,7 @@  int inline_function(struct expression *expr, struct symbol *sym)
 {
 	struct symbol_list * fn_symbol_list;
 	struct symbol *fn = sym->ctype.base_type;
-	struct statement *stmt = alloc_statement(expr->pos, STMT_COMPOUND);
+	struct statement *stmt;
 	struct symbol_list *arg_decl;
 	struct symbol *name;
 	struct expression *arg;
@@ -528,6 +528,7 @@  int inline_function(struct expression *expr, struct symbol *sym)
 	if (fn->expanding)
 		return 0;
 
+	stmt = alloc_statement(expr->pos, STMT_COMPOUND);
 	expr->type = EXPR_STATEMENT;
 	expr->statement = stmt;
 	expr->ctype = fn->ctype.base_type;