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 <[email protected]>
---
lib/ofp-actions.c | 4 +++-
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;
}
--
2.27.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev