Skip to contentSkip to conversation

eal: parse args before any kinds of init

PATCH New Wang Sheng-Hui 1 participant 1 message Apr 15, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: parse args before any kinds of init

Parse args first, to resolve any invalid args and give out the usage string. E.g './helloworld --invalid', the '--invalid' will be checked before any init. After the options are checked, take any init actions.

---
 lib/librte_eal/linuxapp/eal/eal.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +9 -4
index 3ded563..9d20718 100644
@@ -637,6 +637,11 @@ eal_parse_args(int argc, char **argv)
        };
        struct shared_driver *solib;
 
+       /* check the no args case */
+       if (argc == 1) {
+               eal_usage(prgname);
+               return (-1);
+       }
        argvopt = argv;
 
        internal_config.memory = 0;
@@ -964,16 +969,16 @@ rte_eal_init(int argc, char **argv)
 
        thread_id = pthread_self();
 
+       fctret = eal_parse_args(argc, argv);
+       if (fctret < 0)
+               exit(1);
+
        if (rte_eal_log_early_init() < 0)
                rte_panic("Cannot init early logs\n");
 
        if (rte_eal_cpu_init() < 0)
                rte_panic("Cannot detect lcores\n");
 
-       fctret = eal_parse_args(argc, argv);
-       if (fctret < 0)
-               exit(1);
-
        if (internal_config.no_hugetlbfs == 0 &&
                        internal_config.process_type != RTE_PROC_SECONDARY &&
                        internal_config.xen_dom0_support == 0 &&
Signature · 1 line
1.8.3.2