MCPcopy Create free account
hub / github.com/F-Stack/f-stack / eal_parse_args

Function eal_parse_args

dpdk/lib/eal/linux/eal.c:626–824  ·  view source on GitHub ↗

Parse the argument given in the command line of the application */

Source from the content-addressed store, hash-verified

624
625/* Parse the argument given in the command line of the application */
626static int
627eal_parse_args(int argc, char **argv)
628{
629 int opt, ret;
630 char **argvopt;
631 int option_index;
632 char *prgname = argv[0];
633 const int old_optind = optind;
634 const int old_optopt = optopt;
635 char * const old_optarg = optarg;
636 struct internal_config *internal_conf =
637 eal_get_internal_configuration();
638
639 argvopt = argv;
640 optind = 1;
641
642 while ((opt = getopt_long(argc, argvopt, eal_short_options,
643 eal_long_options, &option_index)) != EOF) {
644
645 /* getopt didn't recognise the option */
646 if (opt == '?') {
647 eal_usage(prgname);
648 ret = -1;
649 goto out;
650 }
651
652 /* eal_log_level_parse() already handled this option */
653 if (opt == OPT_LOG_LEVEL_NUM)
654 continue;
655
656 ret = eal_parse_common_option(opt, optarg, internal_conf);
657 /* common parser is not happy */
658 if (ret < 0) {
659 eal_usage(prgname);
660 ret = -1;
661 goto out;
662 }
663 /* common parser handled this option */
664 if (ret == 0)
665 continue;
666
667 switch (opt) {
668 case OPT_HELP_NUM:
669 eal_usage(prgname);
670 exit(EXIT_SUCCESS);
671
672 case OPT_HUGE_DIR_NUM:
673 {
674 char *hdir = strdup(optarg);
675 if (hdir == NULL)
676 RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
677 else {
678 /* free old hugepage dir */
679 free(internal_conf->hugepage_dir);
680 internal_conf->hugepage_dir = hdir;
681 }
682 break;
683 }

Callers 1

rte_eal_initFunction · 0.70

Calls 14

getopt_longFunction · 0.85
eal_parse_common_optionFunction · 0.85
strdupFunction · 0.85
eal_parse_socket_argFunction · 0.85
eal_parse_vfio_intrFunction · 0.85
eal_parse_vfio_vf_tokenFunction · 0.85
isprintFunction · 0.85
eal_create_runtime_dirFunction · 0.85
eal_adjust_configFunction · 0.85
eal_check_common_optionsFunction · 0.85

Tested by

no test coverage detected