aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-02-15 13:39:42 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-18 11:07:19 +0000
commit65a8d06141c405e864b5209047ae5ec4bd4c0f7b (patch)
tree4b1f351d822ede3514b7abc6673eba9f9d48dc2b
parent71134f26a15f3d6b055dc122d050d71f8b8d3ed0 (diff)
tests: policer test check unformat return values
Keep coverity happy by checking the return value of unformat calls. Type: test Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: Iccd0296da527d079f79cc7bd8b57af1b524299bd
-rw-r--r--src/plugins/unittest/policer_test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/unittest/policer_test.c b/src/plugins/unittest/policer_test.c
index 9a0eb845bab..2b14bf687bf 100644
--- a/src/plugins/unittest/policer_test.c
+++ b/src/plugins/unittest/policer_test.c
@@ -30,10 +30,12 @@ policer_test (vlib_main_t *vm, unformat_input_t *input,
policer_t *pol;
vnet_policer_main_t *pm = &vnet_policer_main;
- unformat (input, "index %d", &policer_index); /* policer to use */
- unformat (input, "rate %u", &rate_kbps); /* rate to send at in kbps */
- unformat (input, "burst %u", &burst); /* burst to send in ms */
- unformat (input, "colour %u", &input_colour); /* input colour if aware */
+ if (!unformat (input, "index %d", &policer_index) || /* policer to use */
+ !unformat (input, "rate %u", &rate_kbps) || /* rate to send at in kbps */
+ !unformat (input, "burst %u", &burst) || /* burst to send in ms */
+ !unformat (input, "colour %u",
+ &input_colour)) /* input colour if aware */
+ return clib_error_return (0, "Policer test failed to parse params");
total_bytes = (rate_kbps * burst) / 8;
num_pkts = total_bytes / PKT_LEN;