diff options
author | Jon Loeliger <jdl@netgate.com> | 2017-02-01 12:31:41 -0600 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2017-02-02 17:32:27 +0000 |
commit | 56c7b01e163c233030359781d7e60f4553e90c51 (patch) | |
tree | 6d6ce1f179fdbfa2c2919ac082984fd0bf426f7f /src/vlibapi | |
parent | 1f9191f6efa5f2e0284c194f920093201b27ef81 (diff) |
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 <jdl@netgate.com>
Diffstat (limited to 'src/vlibapi')
-rw-r--r-- | src/vlibapi/vat_helper_macros.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index ffb74fe3b9b..57722338e2a 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -42,32 +42,32 @@ do { \ #define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) /* W: wait for results, with timeout */ -#define W \ +#define W(ret) \ do { \ f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ - return (vam->retval); \ + ret = vam->retval; \ } \ vat_suspend (vam->vlib_main, 1e-5); \ } \ - return -99; \ + ret = -99; \ } while(0); /* W2: wait for results, with timeout */ -#define W2(body) \ +#define W2(ret, body) \ do { \ f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ (body); \ - return (vam->retval); \ + ret = vam->retval; \ } \ vat_suspend (vam->vlib_main, 1e-5); \ } \ - return -99; \ + ret = -99; \ } while(0); |