- int lastarg = i==argc-1;
-
- if (!strcmp(argv[i],"-c") && !lastarg) {
- config.numclients = atoi(argv[i+1]);
- i++;
- } else if (!strcmp(argv[i],"-n") && !lastarg) {
- config.requests = atoi(argv[i+1]);
- i++;
- } else if (!strcmp(argv[i],"-k") && !lastarg) {
- config.keepalive = atoi(argv[i+1]);
- i++;
- } else if (!strcmp(argv[i],"-h") && !lastarg) {
- config.hostip = argv[i+1];
- i++;
- } else if (!strcmp(argv[i],"-p") && !lastarg) {
- config.hostport = atoi(argv[i+1]);
- i++;
- } else if (!strcmp(argv[i],"-s") && !lastarg) {
- config.hostsocket = argv[i+1];
- i++;
- } else if (!strcmp(argv[i],"-d") && !lastarg) {
- config.datasize = atoi(argv[i+1]);
- i++;
+ lastarg = (i == (argc-1));
+
+ if (!strcmp(argv[i],"-c")) {
+ if (lastarg) goto invalid;
+ config.numclients = atoi(argv[++i]);
+ } else if (!strcmp(argv[i],"-n")) {
+ if (lastarg) goto invalid;
+ config.requests = atoi(argv[++i]);
+ } else if (!strcmp(argv[i],"-k")) {
+ if (lastarg) goto invalid;
+ config.keepalive = atoi(argv[++i]);
+ } else if (!strcmp(argv[i],"-h")) {
+ if (lastarg) goto invalid;
+ config.hostip = strdup(argv[++i]);
+ } else if (!strcmp(argv[i],"-p")) {
+ if (lastarg) goto invalid;
+ config.hostport = atoi(argv[++i]);
+ } else if (!strcmp(argv[i],"-s")) {
+ if (lastarg) goto invalid;
+ config.hostsocket = strdup(argv[++i]);
+ } else if (!strcmp(argv[i],"-d")) {
+ if (lastarg) goto invalid;
+ config.datasize = atoi(argv[++i]);