diff options
author | Thomas Haller <thaller@redhat.com> | 2015-10-31 13:51:58 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-10-31 22:30:14 +0100 |
commit | 9ac8e913246d603c612b6083beac5a5ef7e307b2 (patch) | |
tree | df560a8ac70c37642afdcc926788bb1e1a4f08d9 /src/libsystemd-network | |
parent | ed574a6834d267c82cac0408fe977c26256bec9a (diff) |
lldp: avoid compiler warnings in lldp_tfl_package_read* functions
gcc 5.1.1 wrongly warns about uninitialized variable @r2 when compiling
with "-Og". Refactor the code to avoid the warnings.
Fixes: 564cabd46c7c1532ad4d562bf8332eaed49ac201
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/lldp-tlv.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c index 0851957ab4..3c54ea0c43 100644 --- a/src/libsystemd-network/lldp-tlv.c +++ b/src/libsystemd-network/lldp-tlv.c @@ -387,12 +387,11 @@ static int lldp_tlv_packet_read_u16_tlv(tlv_packet *tlv, uint16_t type, uint16_t r = lldp_tlv_packet_enter_container(tlv, type); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, value); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -429,18 +428,18 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_CHASSIS_ID); if (r < 0) - goto out2; + return r; r = tlv_packet_read_u8(tlv, &subtype); if (r < 0) - goto out1; + goto out; switch (subtype) { case LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS: r = tlv_packet_read_bytes(tlv, data, length); if (r < 0) - goto out1; + goto out; break; default: @@ -450,10 +449,9 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, *type = subtype; - out1: + out: r2 = lldp_tlv_packet_exit_container(tlv); - out2: return r < 0 ? r : r2; } @@ -469,11 +467,11 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_PORT_ID); if (r < 0) - goto out2; + return r; r = tlv_packet_read_u8(tlv, &subtype); if (r < 0) - goto out1; + goto out; switch (subtype) { case LLDP_PORT_SUBTYPE_PORT_COMPONENT: @@ -483,7 +481,7 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = tlv_packet_read_string(tlv, &s, length); if (r < 0) - goto out1; + goto out; *data = (uint8_t *) s; @@ -492,7 +490,7 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = tlv_packet_read_bytes(tlv, data, length); if (r < 0) - goto out1; + goto out; break; default: @@ -502,10 +500,9 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, *type = subtype; - out1: + out: r2 = lldp_tlv_packet_exit_container(tlv); - out2: return r < 0 ? r : r2; } @@ -542,12 +539,11 @@ int sd_lldp_packet_read_port_vlan_id(tlv_packet *tlv, uint16_t *id) { r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_VLAN_ID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, id); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -558,7 +554,7 @@ int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flag r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_PROTOCOL_VLAN_ID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u8(tlv, flags); if (r >= 0) @@ -566,7 +562,6 @@ int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flag r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -578,7 +573,7 @@ int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **nam r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_VLAN_NAME); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, vlan_id); if (r >= 0) @@ -591,7 +586,6 @@ int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **nam r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -602,12 +596,11 @@ int sd_lldp_packet_read_management_vid(tlv_packet *tlv, uint16_t *id) { r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_MANAGEMENT_VID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, id); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -618,7 +611,7 @@ int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, u r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_LINK_AGGREGATION); if (r < 0) - goto out; + return r; r = tlv_packet_read_u8(tlv, status); if (r >= 0) @@ -626,7 +619,6 @@ int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, u r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } |