int opt;
char **argvopt;
int option_index;
+ const int old_optind = optind;
+ const int old_optopt = optopt;
+ const int old_optreset = optreset;
+ char * const old_optarg = optarg;
argvopt = argv;
+ optind = 1;
+ optreset = 1;
eal_reset_internal_config(&internal_config);
break;
}
- optind = 0; /* reset getopt lib */
+ /* restore getopt lib */
+ optind = old_optind;
+ optopt = old_optopt;
+ optreset = old_optreset;
+ optarg = old_optarg;
}
/* Parse the argument given in the command line of the application */
char **argvopt;
int option_index;
char *prgname = argv[0];
+ const int old_optind = optind;
+ const int old_optopt = optopt;
+ const int old_optreset = optreset;
+ char * const old_optarg = optarg;
argvopt = argv;
+ optind = 1;
+ optreset = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
- int ret;
-
/* getopt is not happy, stop right now */
if (opt == '?') {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
ret = eal_parse_common_option(opt, optarg, &internal_config);
/* common parser is not happy */
if (ret < 0) {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
/* common parser handled this option */
if (ret == 0)
"on FreeBSD\n", opt);
}
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
}
- if (eal_adjust_config(&internal_config) != 0)
- return -1;
+ if (eal_adjust_config(&internal_config) != 0) {
+ ret = -1;
+ goto out;
+ }
/* sanity checks */
if (eal_check_common_options(&internal_config) != 0) {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
if (optind >= 0)
argv[optind-1] = prgname;
ret = optind-1;
- optind = 0; /* reset getopt lib */
+
+out:
+ /* restore getopt lib */
+ optind = old_optind;
+ optopt = old_optopt;
+ optreset = old_optreset;
+ optarg = old_optarg;
+
return ret;
}
int opt;
char **argvopt;
int option_index;
+ const int old_optind = optind;
+ const int old_optopt = optopt;
+ char * const old_optarg = optarg;
argvopt = argv;
+ optind = 1;
eal_reset_internal_config(&internal_config);
break;
}
- optind = 0; /* reset getopt lib */
+ /* restore getopt lib */
+ optind = old_optind;
+ optopt = old_optopt;
+ optarg = old_optarg;
}
/* Parse the argument given in the command line of the application */
int option_index;
char *prgname = argv[0];
struct shared_driver *solib;
+ const int old_optind = optind;
+ const int old_optopt = optopt;
+ char * const old_optarg = optarg;
argvopt = argv;
+ optind = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
- int ret;
-
/* getopt is not happy, stop right now */
if (opt == '?') {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
ret = eal_parse_common_option(opt, optarg, &internal_config);
/* common parser is not happy */
if (ret < 0) {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
/* common parser handled this option */
if (ret == 0)
solib = malloc(sizeof(*solib));
if (solib == NULL) {
RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
- return -1;
+ ret = -1;
+ goto out;
}
memset(solib, 0, sizeof(*solib));
strncpy(solib->name, optarg, PATH_MAX-1);
RTE_LOG(ERR, EAL, "Can't support DPDK app "
"running on Dom0, please configure"
" RTE_LIBRTE_XEN_DOM0=y\n");
- return -1;
+ ret = -1;
+ goto out;
#endif
break;
RTE_LOG(ERR, EAL, "invalid parameters for --"
OPT_SOCKET_MEM "\n");
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
break;
RTE_LOG(ERR, EAL, "invalid parameter for --"
OPT_BASE_VIRTADDR "\n");
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
break;
RTE_LOG(ERR, EAL, "invalid parameters for --"
OPT_VFIO_INTR "\n");
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
break;
"on Linux\n", opt);
}
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
}
- if (eal_adjust_config(&internal_config) != 0)
- return -1;
+ if (eal_adjust_config(&internal_config) != 0) {
+ ret = -1;
+ goto out;
+ }
/* sanity checks */
if (eal_check_common_options(&internal_config) != 0) {
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
/* --xen-dom0 doesn't make sense with --socket-mem */
RTE_LOG(ERR, EAL, "Options --"OPT_SOCKET_MEM" cannot be specified "
"together with --"OPT_XEN_DOM0"\n");
eal_usage(prgname);
- return -1;
+ ret = -1;
+ goto out;
}
if (optind >= 0)
argv[optind-1] = prgname;
ret = optind-1;
- optind = 0; /* reset getopt lib */
+
+out:
+ /* restore getopt lib */
+ optind = old_optind;
+ optopt = old_optopt;
+ optarg = old_optarg;
+
return ret;
}