summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2015-02-22 16:35:43 -0800
committerBen Pfaff <blp@nicira.com>2015-03-03 16:22:32 -0800
commitf94d6e78047294e5b88364636cb3e50ee58cc283 (patch)
tree2a38c5b870b37d9e71e0b5fd98ac236707b67061 /lib
parenta268e134b6088e8b9d255b19ae1cbb219378c0fe (diff)
downloadopenvswitch-f94d6e78047294e5b88364636cb3e50ee58cc283.tar.gz
lldp: Remove excessive parentheses.
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 <blp@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/lldp/lldp.c9
-rw-r--r--lib/lldp/lldpd.c31
2 files changed, 18 insertions, 22 deletions
diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 0279efb4c..33384b701 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -412,7 +412,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;
@@ -541,7 +541,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;
}
@@ -599,10 +599,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 0c0e441b3..f3d142e15 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -66,9 +66,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;
}
}
@@ -260,9 +259,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();
@@ -304,13 +303,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;
@@ -446,7 +445,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)) {
@@ -499,8 +498,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;
}