[LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list

Petr Vorel pvorel@suse.cz
Fri Sep 9 11:41:10 CEST 2022


Hi all,

> > -	if (argc > 2) {
> > -		fprintf(stderr, "Can't specify multiple fs_type\n");
> > -		usage();
> > -		return 2;
> > +	while ((ret = getopt(argc, argv, "hs:"))) {
> > +		if (ret < 0)
> > +			break;
> > +
> > +		switch (ret) {
> > +		case '?':

> No usage?
Ah, make sense to -? be alias of -h.

> > +			return 1;
> > +
> > +		case 'h':
> > +			usage();
> > +			return 0;
> > +
> > +		case 's':
> > +			fs = optarg;
> > +			for (i = 0; fs[i]; i++) {
> > +				if (optarg[i] == SKIP_DELIMITER)
> > +					cnt++;
> > +			}
> > +			skiplist = malloc(++cnt * sizeof(char *));
> > +			if (!skiplist) {
> > +				fprintf(stderr, "malloc() failed\n");
> > +				return 1;
> > +			}
> > +
> > +			fs = optarg;
> > +			for (i = 0; i < cnt; i++)
> > +				skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
> > +			break;

> It may be a bit cleaner to put this part into a function i.e.

> 	skiplist = parse_skiplist(optarg);

+1, I'll post next version.

Kind regards,
Petr


More information about the ltp mailing list