summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_cli.c
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2017-09-18 08:51:22 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-09-18 18:26:04 +0000
commitb2bcad6238b7e8a669ae29c74079eb9bb9fbb694 (patch)
treea8657766e3ae782ed8dacc4ac1ea559a0e60ae86 /src/vnet/session/session_cli.c
parent2019748a0ef815852281aae0a603f0e970fa9d91 (diff)
Fixes for issues Coverity has reported (VPP-972)
177117: fstat() returns -1 on error; the code is checking for any positive value instead 175142: final return could never be reached; simple refactoring 175235,175236: Warning suppressed with an explicit cast to (void) 174817: Final return couldn't be reached; is is_in_order is 0 then 'rv' is already returned above 172095,172093: If is_is_set does not get set to 1, then return 0 has already been invoked 174405: Re-kill this (nothing sets rv) 171136: Looks like a cmd line flag to set test_bytes was missing; added it, and refactored the argc/argv processing to avoid two other potential segv's 176813: Add range checking for term width/height. First stab at a reasonable range is 1-512 for both. 175350: Fix implicit casting in shift operation 174272: Not a c+p error; try using a coverity annotation to ignore it 174273,175320: Annotated FORWARD_NULL Change-Id: I58d0f860fc2209f59f8d1b6b344d631b8d429ace Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'src/vnet/session/session_cli.c')
-rwxr-xr-xsrc/vnet/session/session_cli.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index d9f516beab9..8c30a1df7eb 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -127,13 +127,8 @@ unformat_stream_session_id (unformat_input_t * input, va_list * args)
*is_ip4 = 0;
tuple_is_set = 1;
}
- else
- return 0;
-
- if (tuple_is_set)
- return 1;
- return 0;
+ return tuple_is_set;
}
uword
@@ -144,21 +139,12 @@ unformat_stream_session (unformat_input_t * input, va_list * args)
u8 proto = ~0;
ip46_address_t lcl, rmt;
u32 lcl_port = 0, rmt_port = 0;
- u8 is_ip4 = 0, s_type = ~0, id_is_set = 0;
+ u8 is_ip4 = 0, s_type = ~0;
- if (unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
- &lcl_port, &rmt_port, &is_ip4))
- {
- id_is_set = 1;
- }
- else
+ if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
+ &lcl_port, &rmt_port, &is_ip4))
return 0;
- if (!id_is_set)
- {
- return 0;
- }
-
s_type = session_type_from_proto_and_ip (proto, is_ip4);
if (is_ip4)
s = stream_session_lookup4 (&lcl.ip4, &rmt.ip4,
@@ -185,21 +171,12 @@ unformat_transport_connection (unformat_input_t * input, va_list * args)
u8 proto = ~0;
ip46_address_t lcl, rmt;
u32 lcl_port = 0, rmt_port = 0;
- u8 is_ip4 = 0, s_type = ~0, id_is_set = 0;
+ u8 is_ip4 = 0, s_type = ~0;
- if (unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
- &lcl_port, &rmt_port, &is_ip4))
- {
- id_is_set = 1;
- }
- else
+ if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
+ &lcl_port, &rmt_port, &is_ip4))
return 0;
- if (!id_is_set)
- {
- return 0;
- }
-
proto = (proto == (u8) ~ 0) ? suggested_proto : proto;
if (proto == (u8) ~ 0)
return 0;