summaryrefslogtreecommitdiffstats
path: root/src/uri/uri_socket_test.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/uri/uri_socket_test.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/uri/uri_socket_test.c')
-rw-r--r--src/uri/uri_socket_test.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/uri/uri_socket_test.c b/src/uri/uri_socket_test.c
index 5f7084d5b20..4469b03d4c2 100644
--- a/src/uri/uri_socket_test.c
+++ b/src/uri/uri_socket_test.c
@@ -36,8 +36,6 @@ main (int argc, char *argv[])
if (argc >= 3)
{
- bytes = ((long) atoi (argv[4])) << 20;
- no_echo = atoi (argv[3]);
portno = atoi (argv[2]);
server = gethostbyname (argv[1]);
if (server == NULL)
@@ -45,6 +43,28 @@ main (int argc, char *argv[])
clib_unix_warning ("gethostbyname");
exit (1);
}
+
+ argc -= 3;
+ argv += 3;
+
+ if (argc)
+ {
+ bytes = ((long) atoi (argv[0])) << 20;
+ argc--;
+ argv++;
+ }
+ if (argc)
+ {
+ no_echo = atoi (argv[0]);
+ argc--;
+ argv++;
+ }
+ if (argc)
+ {
+ test_bytes = atoi (argv[0]);
+ argc--;
+ argv++;
+ }
}
else
{