The OVS style is to usually avoid parentheses in cases like these where they just make expressions harder to read.
Signed-off-by: Ben Pfaff <b...@nicira.com> --- lib/lldp/lldp.c | 9 +++------ lib/lldp/lldpd.c | 31 +++++++++++++++---------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c index 8fece07..53388af 100644 --- a/lib/lldp/lldp.c +++ b/lib/lldp/lldp.c @@ -409,7 +409,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int s, case LLDP_TLV_PORT_ID: CHECK_TLV_SIZE(2, "Port Id"); tlv_subtype = PEEK_UINT8; - if ((tlv_subtype == 0) || (tlv_subtype > 7)) { + if (tlv_subtype == 0 || tlv_subtype > 7) { VLOG_WARN("unknown subtype for tlv id received on %s", hardware->h_ifname); goto malformed; @@ -538,7 +538,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int s, */ num_mappings = tlv_size - 4 - LLDP_TLV_AA_ISID_VLAN_DIGEST_LENGTH; - if ((num_mappings % 5) != 0) { + if (num_mappings % 5 != 0) { VLOG_INFO("malformed vlan-isid mappings tlv received"); goto malformed; } @@ -596,10 +596,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int s, } /* Some random check */ - if ((chassis->c_id == NULL) || - (port->p_id == NULL) || - (!ttl_received) || - (gotend == 0)) { + if (!chassis->c_id || !port->p_id || !ttl_received || !gotend) { VLOG_WARN("some mandatory tlv are missing for frame received " "on %s", hardware->h_ifname); goto malformed; diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c index 4467960..8259e9d 100644 --- a/lib/lldp/lldpd.c +++ b/lib/lldp/lldpd.c @@ -65,9 +65,8 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index, struct lldpd_hardware *hw; LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware.h_entries) { - if ((strcmp(hw->h_ifname, name) == 0) && - (hw->h_ifindex == index) && - ((!ops) || (ops == hw->h_ops))) { + if (!strcmp(hw->h_ifname, name) && hw->h_ifindex == index + && (!ops || ops == hw->h_ops)) { return hw; } } @@ -259,9 +258,9 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s, } LIST_FOR_EACH (oport, p_entries, &hw->h_rports) { - if ((oport->p_lastframe != NULL) && - (oport->p_lastframe->size == s) && - (memcmp(oport->p_lastframe->frame, frame, s) == 0)) { + if (oport->p_lastframe && + oport->p_lastframe->size == s && + !memcmp(oport->p_lastframe->frame, frame, s)) { /* Already received the same frame */ VLOG_DBG("duplicate frame, no need to decode"); oport->p_lastupdate = time_now(); @@ -303,13 +302,13 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s, LIST_FOR_EACH (oport, p_entries, &hw->h_rports) { if (port->p_protocol == oport->p_protocol) { count++; - if ((port->p_id_subtype == oport->p_id_subtype) && - (port->p_id_len == oport->p_id_len) && - (memcmp(port->p_id, oport->p_id, port->p_id_len) == 0) && - (chassis->c_id_subtype == oport->p_chassis->c_id_subtype) && - (chassis->c_id_len == oport->p_chassis->c_id_len) && - (memcmp(chassis->c_id, oport->p_chassis->c_id, - chassis->c_id_len) == 0)) { + if (port->p_id_subtype == oport->p_id_subtype && + port->p_id_len == oport->p_id_len && + !memcmp(port->p_id, oport->p_id, port->p_id_len) && + chassis->c_id_subtype == oport->p_chassis->c_id_subtype && + chassis->c_id_len == oport->p_chassis->c_id_len && + !memcmp(chassis->c_id, oport->p_chassis->c_id, + chassis->c_id_len)) { ochassis = oport->p_chassis; VLOG_DBG("MSAP is already known"); found = true; @@ -445,7 +444,7 @@ lldpd_hide_ports(struct lldpd *cfg, } } for (i = 0; i <= LLDPD_MODE_MAX; i++) { - if ((protocols[i] == min) && !found) { + if (protocols[i] == min && !found) { /* If we need a tie breaker, we take the first protocol only */ if (cfg->g_config.c_smart & mask & (SMART_OUTGOING_ONE_PROTO | SMART_INCOMING_ONE_PROTO)) { @@ -498,8 +497,8 @@ lldpd_hide_ports(struct lldpd *cfg, k = j = 0; LIST_FOR_EACH (port, p_entries, &hw->h_rports) { - if (!(((mask == SMART_OUTGOING) && port->p_hidden_out) || - ((mask == SMART_INCOMING) && port->p_hidden_in))) { + if (!((mask == SMART_OUTGOING && port->p_hidden_out) || + (mask == SMART_INCOMING && port->p_hidden_in))) { k++; protocols[port->p_protocol] = 1; } -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev