From d2c8dcfd8f0ca03d3d82abc1933f3cad4803aee7 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 31 Mar 2022 13:50:21 +0100 Subject: dpdk: fix coverity issue Type: fix This patch fixes the following DPDK plugin issue: CID 253333: Control flow issues (DEADCODE) The change also includes some cosmetic changes for error handling. Signed-off-by: Fan Zhang Change-Id: I830020bc3ae9a508f3a905f78333fa3ae25ce784 --- src/plugins/dpdk/device/init.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 940c03055ad..a94f83bc42d 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -1145,12 +1145,8 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) else if (unformat_skip_white_space (input)) ; - else - { - error = clib_error_return (0, "unknown input `%U'", + else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); - goto done; - } } if (!conf->uio_driver_name) @@ -1192,9 +1188,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) vec_add1 (conf->eal_init_args, tmp); } - if (error) - return error; - if (no_pci == 0 && geteuid () == 0) dpdk_bind_devices_to_uio (conf); @@ -1300,6 +1293,8 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) dpdk_log_notice ("EAL init args: %s", conf->eal_init_args_str); ret = rte_eal_init (vec_len (conf->eal_init_args), (char **) conf->eal_init_args); + if (ret < 0) + return clib_error_return (0, "rte_eal_init returned %d", ret); /* enable the AVX-512 vPMDs in DPDK */ if (clib_cpu_supports_avx512_bitalg () && @@ -1316,15 +1311,11 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) rmdir ((char *) huge_dir_path); vec_free (huge_dir_path); - if (ret < 0) - return clib_error_return (0, "rte_eal_init returned %d", ret); - /* main thread 1st */ if ((error = dpdk_buffer_pools_create (vm))) return error; -done: - return error; + return 0; } VLIB_CONFIG_FUNCTION (dpdk_config, "dpdk"); -- cgit 1.2.3-korg