MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ff_parse_args

Function ff_parse_args

lib/ff_config.c:1190–1229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1188}
1189
1190static int
1191ff_parse_args(struct ff_config *cfg, int argc, char *const argv[])
1192{
1193 int c;
1194 int index = 0;
1195 optind = 1;
1196 while((c = getopt_long(argc, argv, short_options, long_options, &index)) != -1) {
1197 switch (c) {
1198 case 'c':
1199 cfg->filename = strdup(optarg);
1200 break;
1201 case 'p':
1202 cfg->dpdk.proc_id = atoi(optarg);
1203 break;
1204 case 't':
1205 cfg->dpdk.proc_type = strdup(optarg);
1206 break;
1207 default:
1208 return -1;
1209 }
1210 }
1211
1212 if (cfg->dpdk.proc_type == NULL) {
1213 cfg->dpdk.proc_type = strdup("auto");
1214 }
1215
1216 if (strcmp(cfg->dpdk.proc_type, "primary") &&
1217 strcmp(cfg->dpdk.proc_type, "secondary") &&
1218 strcmp(cfg->dpdk.proc_type, "auto")) {
1219 printf("invalid proc-type:%s\n", cfg->dpdk.proc_type);
1220 return -1;
1221 }
1222
1223 if ((uint16_t)cfg->dpdk.proc_id > RTE_MAX_LCORE) {
1224 printf("invalid proc_id:%d, use default 0\n", cfg->dpdk.proc_id);
1225 cfg->dpdk.proc_id = 0;
1226 }
1227
1228 return 0;
1229}
1230
1231static int
1232ff_check_config(struct ff_config *cfg)

Callers 1

ff_load_configFunction · 0.85

Calls 4

getopt_longFunction · 0.85
strdupFunction · 0.85
strcmpFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected