From 3d84a7208988ad641599271d5bfde078c2fc9b4c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 16 Nov 2015 09:06:07 +0100 Subject: lookup: Convert __do_lookup_inline to function Make __do_lookup_inline an inline function and shorten its name to __lookup_inline. Signed-off-by: Tobias Klauser --- lookup.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lookup.c') diff --git a/lookup.c b/lookup.c index a8dfe20..516ca7c 100644 --- a/lookup.c +++ b/lookup.c @@ -127,32 +127,32 @@ void lookup_cleanup(enum lookup_type which) lookup_initialized[which] = false; } -#define __do_lookup_inline(id, hash_ptr) \ - ({ \ - struct lookup_entry *entry = lookup_hash(id, hash_ptr); \ - \ - while (entry && id != entry->id) \ - entry = entry->next; \ - \ - (entry && id == entry->id ? entry->str : NULL); \ - }) +static inline char *__lookup_inline(unsigned int id, struct hash_table *tbl) +{ + struct lookup_entry *entry = lookup_hash(id, tbl); + + while (entry && id != entry->id) + entry = entry->next; + + return (entry && id == entry->id ? entry->str : NULL); +} char *lookup_ether_type(unsigned int id) { - return __do_lookup_inline(id, &lookup_tables[LT_ETHERTYPES]); + return __lookup_inline(id, &lookup_tables[LT_ETHERTYPES]); } char *lookup_port_udp(unsigned int id) { - return __do_lookup_inline(id, &lookup_tables[LT_PORTS_UDP]); + return __lookup_inline(id, &lookup_tables[LT_PORTS_UDP]); } char *lookup_port_tcp(unsigned int id) { - return __do_lookup_inline(id, &lookup_tables[LT_PORTS_TCP]); + return __lookup_inline(id, &lookup_tables[LT_PORTS_TCP]); } char *lookup_vendor(unsigned int id) { - return __do_lookup_inline(id, &lookup_tables[LT_OUI]); + return __lookup_inline(id, &lookup_tables[LT_OUI]); } -- cgit v1.2.3-54-g00ecf