[PATCH 05/13] add get_nth1_arg()

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

 



A backend may need to know the size or the type of an
argument and there is no easy way to access to this info.

Fix this by adding an helper returning the symbol associated
to the nth argument (starting at 1).

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 symbol.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/symbol.h b/symbol.h
index 36f8345b5..2bc0e21a0 100644
--- a/symbol.h
+++ b/symbol.h
@@ -416,6 +416,19 @@ static inline int get_sym_type(struct symbol *type)
 	return type->type;
 }
 
+static inline struct symbol *get_nth1_arg(struct symbol *fn, int idx)
+{
+	struct symbol_list *args = fn->ctype.base_type->arguments;
+	struct symbol *arg;
+	int i = 0;
+	FOR_EACH_PTR(args, arg) {
+		if (++i == idx)
+			return arg;
+	} END_FOR_EACH_PTR(arg);
+
+	return NULL;
+}
+
 static inline struct symbol *lookup_keyword(struct ident *ident, enum namespace ns)
 {
 	if (!ident->keyword)
-- 
2.11.1

--
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