From 56c7b01e163c233030359781d7e60f4553e90c51 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Wed, 1 Feb 2017 12:31:41 -0600 Subject: Refactor fragile msg macro W and W2 to not burry return control flow. Instead, have them accept and assign a return paramter leaving the return control flow up to the caller. Clean up otherwise misleading returns present even after "NOT REACHED" comments. Change-Id: I0861921f73ab65d55b95eabd27514f0129152723 Signed-off-by: Jon Loeliger --- src/plugins/acl/acl_test.c | 52 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'src/plugins/acl/acl_test.c') diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 39d7e1c4848..23dc6bc0c84 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -267,6 +267,7 @@ static int api_acl_plugin_get_version (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); + int ret; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -278,9 +279,8 @@ static int api_acl_plugin_get_version (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; - - return 0; + W (ret); + return ret; } static int api_macip_acl_interface_get (vat_main_t * vam) @@ -288,6 +288,7 @@ static int api_macip_acl_interface_get (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); + int ret; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -299,9 +300,8 @@ static int api_macip_acl_interface_get (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; - - return 0; + W (ret); + return ret; } #define vec_validate_acl_rules(v, idx) \ @@ -335,6 +335,7 @@ static int api_acl_add_replace (vat_main_t * vam) ip4_address_t src_v4address, dst_v4address; ip6_address_t src_v6address, dst_v6address; u8 *tag = 0; + int ret; if (!unformat (i, "%d", &acl_index)) { /* Just assume -1 */ @@ -479,7 +480,8 @@ static int api_acl_add_replace (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_del (vat_main_t * vam) @@ -487,6 +489,7 @@ static int api_acl_del (vat_main_t * vam) unformat_input_t * i = vam->input; vl_api_acl_del_t * mp; u32 acl_index = ~0; + int ret; if (!unformat (i, "%d", &acl_index)) { errmsg ("missing acl index\n"); @@ -501,7 +504,8 @@ static int api_acl_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_del (vat_main_t * vam) @@ -509,6 +513,7 @@ static int api_macip_acl_del (vat_main_t * vam) unformat_input_t * i = vam->input; vl_api_acl_del_t * mp; u32 acl_index = ~0; + int ret; if (!unformat (i, "%d", &acl_index)) { errmsg ("missing acl index\n"); @@ -523,7 +528,8 @@ static int api_macip_acl_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_interface_add_del (vat_main_t * vam) @@ -534,6 +540,7 @@ static int api_acl_interface_add_del (vat_main_t * vam) u32 acl_index = ~0; u8 is_input = 0; u8 is_add = 0; + int ret; // acl_interface_add_del | sw_if_index acl_index [out] [del] @@ -589,7 +596,8 @@ static int api_acl_interface_add_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_interface_add_del (vat_main_t * vam) @@ -599,6 +607,7 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) u32 sw_if_index = ~0; u32 acl_index = ~0; u8 is_add = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -638,7 +647,8 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_interface_set_acl_list (vat_main_t * vam) @@ -650,6 +660,7 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) u32 *inacls = 0; u32 *outacls = 0; u8 is_input = 0; + int ret; // acl_interface_set_acl_list | sw_if_index input [acl-idx list] output [acl-idx list] @@ -694,7 +705,8 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } @@ -703,6 +715,7 @@ static int api_acl_interface_list_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 sw_if_index = ~0; vl_api_acl_interface_list_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -722,7 +735,8 @@ static int api_acl_interface_list_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_dump (vat_main_t * vam) @@ -730,6 +744,7 @@ static int api_acl_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 acl_index = ~0; vl_api_acl_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -747,7 +762,8 @@ static int api_acl_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_dump (vat_main_t * vam) @@ -755,6 +771,7 @@ static int api_macip_acl_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 acl_index = ~0; vl_api_acl_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -772,7 +789,8 @@ static int api_macip_acl_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } #define vec_validate_macip_acl_rules(v, idx) \ @@ -801,6 +819,7 @@ static int api_macip_acl_add (vat_main_t * vam) u8 src_mac[6]; u8 *tag = 0; u8 mac_mask_all_1[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -903,7 +922,8 @@ static int api_macip_acl_add (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* -- cgit 1.2.3-korg