diff options
author | Mike Pattrick <mkp@redhat.com> | 2022-02-27 20:56:09 -0500 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-03-11 21:16:02 +0100 |
commit | 3bd593917c214f0e92201ba4597f4bd582cf7200 (patch) | |
tree | 407b2780e9cf4525b6557b1698da95bda03514b4 | |
parent | b1e783dde42dc589d416753ae3d6c8585b7fb7da (diff) | |
download | openvswitch-3bd593917c214f0e92201ba4597f4bd582cf7200.tar.gz |
ofp-prop: Silence the 'may be uninitialized' warning.
GCC 11.2.1-2.2 emits a false-positive warnings like:
lib/ofp-packet.c: In function 'ofputil_decode_packet_in':
lib/ofp-packet.c:155:25: warning: 'reason' may be used
uninitialized [-Wmaybe-uninitialized]
lib/ofp-packet.c: In function 'ofputil_decode_packet_in_private':
lib/ofp-packet.c:886:27: warning: 'value' may be used
uninitialized [-Wmaybe-uninitialized]
Modifying callers of ofpprop_parse_* functions to always check
the return value before using the value from these functions.
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r-- | lib/ofp-actions.c | 4 | ||||
-rw-r--r-- | lib/ofp-packet.c | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 006837c2e..a0b70a89d 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -853,7 +853,9 @@ decode_NXAST_RAW_CONTROLLER2(const struct ext_action_header *eah, case NXAC2PT_REASON: { uint8_t u8; error = ofpprop_parse_u8(&payload, &u8); - oc->reason = u8; + if (!error) { + oc->reason = u8; + } break; } diff --git a/lib/ofp-packet.c b/lib/ofp-packet.c index 4579548ee..9485ddfc9 100644 --- a/lib/ofp-packet.c +++ b/lib/ofp-packet.c @@ -133,7 +133,9 @@ decode_nx_packet_in2(const struct ofp_header *oh, bool loose, case NXPINT_FULL_LEN: { uint32_t u32; error = ofpprop_parse_u32(&payload, &u32); - *total_len = u32; + if (!error) { + *total_len = u32; + } break; } @@ -152,7 +154,9 @@ decode_nx_packet_in2(const struct ofp_header *oh, bool loose, case NXPINT_REASON: { uint8_t reason; error = ofpprop_parse_u8(&payload, &reason); - pin->reason = reason; + if (!error) { + pin->reason = reason; + } break; } @@ -883,7 +887,9 @@ ofputil_decode_packet_in_private(const struct ofp_header *oh, bool loose, case NXCPT_ODP_PORT: { uint32_t value; error = ofpprop_parse_u32(&payload, &value); - pin->odp_port = u32_to_odp(value); + if (!error) { + pin->odp_port = u32_to_odp(value); + } break; } |