Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/systat/devs.c
Show All 12 Lines | |||||
*/ | */ | ||||
tmpstr = tmpstr1 = strdup(args); | tmpstr = tmpstr1 = strdup(args); | ||||
for (tempstr = tstr, num_args = 0; | for (tempstr = tstr, num_args = 0; | ||||
(*tempstr = strsep(&tmpstr1, "|")) != NULL && (num_args < 100); | (*tempstr = strsep(&tmpstr1, "|")) != NULL && (num_args < 100); | ||||
num_args++) | num_args++) | ||||
if (**tempstr != '\0') | if (**tempstr != '\0') | ||||
if (++tempstr >= &tstr[100]) | if (++tempstr >= &tstr[100]) | ||||
break; | break; | ||||
free(tmpstr); | |||||
if (num_args > 99) { | if (num_args > 99) { | ||||
warnx("dsmatchselect: too many match arguments"); | warnx("dsmatchselect: too many match arguments"); | ||||
free(tmpstr); | |||||
return(0); | return(0); | ||||
} | } | ||||
/* | /* | ||||
* If we've gone through the matching code before, clean out | * If we've gone through the matching code before, clean out | ||||
* previously used memory. | * previously used memory. | ||||
*/ | */ | ||||
if (num_matches > 0) { | if (num_matches > 0) { | ||||
free(matches); | free(matches); | ||||
matches = NULL; | matches = NULL; | ||||
num_matches = 0; | num_matches = 0; | ||||
} | } | ||||
for (i = 0; i < num_args; i++) { | for (i = 0; i < num_args; i++) { | ||||
if (devstat_buildmatch(tstr[i], &matches, &num_matches) != 0) { | if (devstat_buildmatch(tstr[i], &matches, &num_matches) != 0) { | ||||
warnx("%s", devstat_errbuf); | warnx("%s", devstat_errbuf); | ||||
free(tmpstr); | |||||
return(0); | return(0); | ||||
} | } | ||||
} | } | ||||
free(tmpstr); | |||||
if (num_args > 0) { | if (num_args > 0) { | ||||
last_type = DS_MATCHTYPE_PATTERN; | last_type = DS_MATCHTYPE_PATTERN; | ||||
retval = devstat_selectdevs(&dev_select, &num_selected, | retval = devstat_selectdevs(&dev_select, &num_selected, | ||||
&num_selections, &select_generation, generation, | &num_selections, &select_generation, generation, | ||||
s1->dinfo->devices, num_devices, matches, num_matches, | s1->dinfo->devices, num_devices, matches, num_matches, | ||||
NULL, 0, select_mode, maxshowdevs, 0); | NULL, 0, select_mode, maxshowdevs, 0); | ||||
Show All 12 Lines |