[PATCH 2/2] llvm: initialize at declaration time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In sym_func_type(), a few variables are initialized
just after they are declared.

Change this to initialize them directly at their
declaration, which is simpler and more idiomatic.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 sparse-llvm.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 96b1499de..2f296ead4 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -34,26 +34,19 @@ static LLVMTypeRef func_return_type(struct symbol *sym)
 
 static LLVMTypeRef sym_func_type(struct symbol *sym)
 {
-	LLVMTypeRef *arg_type;
-	LLVMTypeRef func_type;
-	LLVMTypeRef ret_type;
+	int n_arg = symbol_list_size(sym->arguments);
+	LLVMTypeRef *arg_type = calloc(n_arg, sizeof(LLVMTypeRef));
+	LLVMTypeRef ret_type = func_return_type(sym);
 	struct symbol *arg;
-	int n_arg;
-
-	ret_type = func_return_type(sym);
-	n_arg = symbol_list_size(sym->arguments);
-	arg_type = calloc(n_arg, sizeof(LLVMTypeRef));
-
 	int idx = 0;
+
 	FOR_EACH_PTR(sym->arguments, arg) {
 		struct symbol *arg_sym = arg->ctype.base_type;
 
 		arg_type[idx++] = symbol_type(arg_sym);
 	} END_FOR_EACH_PTR(arg);
-	func_type = LLVMFunctionType(ret_type, arg_type, n_arg,
-				     sym->variadic);
 
-	return func_type;
+	return LLVMFunctionType(ret_type, arg_type, n_arg, sym->variadic);
 }
 
 static LLVMTypeRef sym_array_type(struct symbol *sym)
-- 
2.16.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux