t/latency_percentiles.py: correct terse parse
[fio.git] / init.c
diff --git a/init.c b/init.c
index 6ff7c68d72de1329ceb2ab8e84709dcd3519f1e2..7f64ce21a36aec1bedf4d609f7cb63866923643a 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1735,11 +1735,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                if (file_alloced) {
                        if (td_new->files) {
                                struct fio_file *f;
-                               for_each_file(td_new, f, i) {
-                                       if (f->file_name)
-                                               sfree(f->file_name);
-                                       sfree(f);
-                               }
+                               for_each_file(td_new, f, i)
+                                       fio_file_free(f);
                                free(td_new->files);
                                td_new->files = NULL;
                        }
@@ -1838,6 +1835,7 @@ static int __parse_jobs_ini(struct thread_data *td,
                int nested, char *name, char ***popts, int *aopts, int *nopts)
 {
        bool global = false;
+       bool stdin_occupied = false;
        char *string;
        FILE *f;
        char *p;
@@ -1854,9 +1852,10 @@ static int __parse_jobs_ini(struct thread_data *td,
        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) {
@@ -2059,15 +2058,17 @@ static int __parse_jobs_ini(struct thread_data *td,
 
                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) {
@@ -2542,7 +2543,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                case 'i':
                        did_arg = true;
                        if (!cur_client) {
-                               fio_show_ioengine_help(optarg);
+                               exit_val = fio_show_ioengine_help(optarg);
                                do_exit++;
                        }
                        break;
@@ -2894,7 +2895,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        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;