if (file_alloced) {
if (td_new->files) {
struct fio_file *f;
- for_each_file(td_new, f, i) {
- bool use_smalloc = fio_file_smalloc(f);
- if (f->file_name) {
- if (use_smalloc)
- sfree(f->file_name);
- else
- free(f->file_name);
- }
- if (use_smalloc)
- sfree(f);
- else
- free(f);
- }
+ for_each_file(td_new, f, i)
+ fio_file_free(f);
free(td_new->files);
td_new->files = NULL;
}
int nested, char *name, char ***popts, int *aopts, int *nopts)
{
bool global = false;
+ bool stdin_occupied = false;
char *string;
FILE *f;
char *p;
if (is_buf)
f = NULL;
else {
- if (!strcmp(file, "-"))
+ if (!strcmp(file, "-")) {
f = stdin;
- else
+ stdin_occupied = true;
+ } else
f = fopen(file, "r");
if (!f) {
ret = fio_options_parse(td, opts, num_opts);
- if (!ret) {
- if (!strcmp(file, "-") && td->o.read_iolog_file != NULL) {
- char *fname = get_name_by_idx(td->o.read_iolog_file,
- td->subjob_number);
- if (!strcmp(fname, "-")) {
- log_err("fio: we can't read both iolog "
- "and job file from stdin.\n");
+ if (!ret && td->o.read_iolog_file != NULL) {
+ char *fname = get_name_by_idx(td->o.read_iolog_file,
+ td->subjob_number);
+ if (!strcmp(fname, "-")) {
+ if (stdin_occupied) {
+ log_err("fio: only one user (read_iolog_file/job "
+ "file) of stdin is permitted at once but "
+ "more than one was found.\n");
ret = 1;
}
+ stdin_occupied = true;
}
}
if (!ret) {
case 'i':
did_arg = true;
if (!cur_client) {
- fio_show_ioengine_help(optarg);
+ exit_val = fio_show_ioengine_help(optarg);
do_exit++;
}
break;
log_err("%s: unrecognized option '%s'\n", argv[0],
argv[optind - 1]);
show_closest_option(argv[optind - 1]);
- /* fall through */
+ fallthrough;
default:
do_exit++;
exit_val = 1;