{ .keyword = NULL, },
};
-static char *make_filename(char *buf, struct thread_options *o,
+static char *make_filename(char *buf, size_t buf_size,struct thread_options *o,
const char *jobname, int jobnum, int filenum)
{
struct fpre_keyword *f;
char copy[PATH_MAX];
- size_t dst_left = PATH_MAX;
+ size_t dst_left = PATH_MAX - 1;
if (!o->filename_format || !strlen(o->filename_format)) {
sprintf(buf, "%s.%d.%d", jobname, jobnum, filenum);
for (f = &fpre_keywords[0]; f->keyword; f++)
f->strlen = strlen(f->keyword);
- strcpy(buf, o->filename_format);
+ buf[buf_size - 1] = '\0';
+ strncpy(buf, o->filename_format, buf_size - 1);
+
memset(copy, 0, sizeof(copy));
for (f = &fpre_keywords[0]; f->keyword; f++) {
do {
if (post_start)
strncpy(dst, buf + post_start, dst_left);
- strcpy(buf, copy);
+ strncpy(buf, copy, buf_size - 1);
} while (1);
}
add_file(td, jobname, job_add_num, 0);
else {
for (i = 0; i < o->nr_files; i++)
- add_file(td, make_filename(fname, o, jobname, job_add_num, i), job_add_num, 0);
+ add_file(td, make_filename(fname, sizeof(fname), o, jobname, job_add_num, i), job_add_num, 0);
}
}
optind = 1;
while ((c = getopt_long_only(argc, argv, ostr, l_opts, &lidx)) != -1) {
- did_arg = 1;
-
if ((c & FIO_CLIENT_FLAG) || client_flag_set(c)) {
parse_cmd_client(cur_client, argv[optind - 1]);
c &= ~FIO_CLIENT_FLAG;
append_terse_output = 1;
break;
case 'h':
+ did_arg = 1;
if (!cur_client) {
usage(argv[0]);
do_exit++;
}
break;
case 'c':
+ did_arg = 1;
if (!cur_client) {
fio_show_option_help(optarg);
do_exit++;
}
break;
case 'i':
+ did_arg = 1;
if (!cur_client) {
fio_show_ioengine_help(optarg);
do_exit++;
}
break;
case 's':
+ did_arg = 1;
dump_cmdline = 1;
break;
case 'r':
read_only = 1;
break;
case 'v':
+ did_arg = 1;
if (!cur_client) {
log_info("%s\n", fio_version_string);
do_exit++;
do_exit++;
break;
case 'P':
+ did_arg = 1;
parse_only = 1;
break;
case 'x': {
break;
}
case 'p':
+ did_arg = 1;
if (exec_profile)
free(exec_profile);
exec_profile = strdup(optarg);
if (ret)
goto out_free;
td = NULL;
+ did_arg = 1;
}
if (!td) {
int is_section = !strncmp(opt, "name", 4);
case FIO_GETOPT_IOENGINE: {
const char *opt = l_opts[lidx].name;
char *val = optarg;
+
+ if (!td)
+ break;
+
ret = fio_cmd_ioengine_option_parse(td, opt, val);
break;
}
}
break;
case 'S':
+ did_arg = 1;
if (nr_clients) {
log_err("fio: can't be both client and server\n");
do_exit++;
backend = 1;
break;
case 'D':
+ if (pid_file)
+ free(pid_file);
pid_file = strdup(optarg);
break;
case 'I':
if ((ret = fio_idle_prof_parse_opt(optarg))) {
/* exit on error and calibration only */
+ did_arg = 1;
do_exit++;
- if (ret == -1)
+ if (ret == -1)
exit_val = 1;
}
break;
case 'C':
+ did_arg = 1;
if (is_backend) {
log_err("fio: can't be both client and server\n");
do_exit++;
}
break;
case 'T':
+ did_arg = 1;
do_exit++;
exit_val = fio_monotonic_clocktest();
break;
case 'G':
+ did_arg = 1;
do_exit++;
exit_val = fio_crctest(optarg);
break;
free(pid_file);
if (td) {
- if (!ret)
+ if (!ret) {
ret = add_job(td, td->o.name ?: "fio", 0, 0, client_type);
+ if (ret)
+ did_arg = 1;
+ }
}
while (!ret && optind < argc) {