From 1513872fa4afa46c16b0cab267db40db38502a85 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 14 Jun 2013 14:51:34 +0200 Subject: dissector: lldp: Rework capability printing Make printing of capabilities a bit more intuitive by removing the inline post-increment. This should also make the Coverity scanner happy about this particular part. Signed-off-by: Tobias Klauser --- proto_lldp.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/proto_lldp.c b/proto_lldp.c index 205c899..9301281 100644 --- a/proto_lldp.c +++ b/proto_lldp.c @@ -122,26 +122,32 @@ static int lldp_print_net_addr(const uint8_t *addr, size_t addrlen) return 0; } +static inline void lldp_print_cap_one(const char *cap, unsigned int *prev) +{ + tprintf("%s%s", *prev ? ", " : "", cap); + (*prev)++; +} + static void lldp_print_cap(uint16_t cap) { unsigned int prev = 0; if (cap & LLDP_SYSTEM_CAP_OTHER) - tprintf("%sOther", prev++ ? ", " : ""); + lldp_print_cap_one("Other", &prev); if (cap & LLDP_SYSTEM_CAP_REPEATER) - tprintf("%sRepeater", prev++ ? ", " : ""); + lldp_print_cap_one("Repeater", &prev); if (cap & LLDP_SYSTEM_CAP_BRIDGE) - tprintf("%sBridge", prev++ ? ", " : ""); + lldp_print_cap_one("Bridge", &prev); if (cap & LLDP_SYSTEM_CAP_WLAN_AP) - tprintf("%sWLAN AP", prev++ ? ", " : ""); + lldp_print_cap_one("WLAN AP", &prev); if (cap & LLDP_SYSTEM_CAP_ROUTER) - tprintf("%sRouter", prev++ ? ", " : ""); + lldp_print_cap_one("Router", &prev); if (cap & LLDP_SYSTEM_CAP_TELEPHONE) - tprintf("%sTelephone", prev++ ? ", " : ""); + lldp_print_cap_one("Telephone", &prev); if (cap & LLDP_SYSTEM_CAP_DOCSIS) - tprintf("%sDOCSIS", prev++ ? ", " : ""); + lldp_print_cap_one("DOCSIS", &prev); if (cap & LLDP_SYSTEM_CAP_STATION_ONLY) - tprintf("%sStation only", prev++ ? ", " : ""); + lldp_print_cap_one("Station only", &prev); } static void lldp(struct pkt_buff *pkt) -- cgit v1.2.3-54-g00ecf