dpdk: fix coverity issue 44/35844/4
authorFan Zhang <roy.fan.zhang@intel.com>
Thu, 31 Mar 2022 12:50:21 +0000 (13:50 +0100)
committerDamjan Marion <dmarion@me.com>
Fri, 1 Apr 2022 15:42:23 +0000 (15:42 +0000)
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 <roy.fan.zhang@intel.com>
Change-Id: I830020bc3ae9a508f3a905f78333fa3ae25ce784

src/plugins/dpdk/device/init.c

index 940c030..a94f83b 100644 (file)
@@ -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");