diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-11-16 09:06:07 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-11-16 09:07:30 +0100 |
commit | 3d84a7208988ad641599271d5bfde078c2fc9b4c (patch) | |
tree | 8658bae75e587b3569a967bdb1a6c351f3b229b8 | |
parent | 04b2adac4e5d460f39454b59ed4f2d3374cb796b (diff) |
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 <tklauser@distanz.ch>
-rw-r--r-- | lookup.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -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]); } |