projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
init: use 'bool' for get_new_job()
[fio.git]
/
init.c
diff --git
a/init.c
b/init.c
index c3cc3e54a38f514804a3b095c175f2a23e9b32ff..fabc887b06c75c737e8eb49632f8bebe11e28c47 100644
(file)
--- a/
init.c
+++ b/
init.c
@@
-356,6
+356,9
@@
static int setup_thread_area(void)
perror("shmat");
return 1;
}
perror("shmat");
return 1;
}
+#ifdef FIO_HAVE_SHM_ATTACH_REMOVED
+ shmctl(shm_id, IPC_RMID, NULL);
+#endif
#endif
memset(threads, 0, max_jobs * sizeof(struct thread_data));
#endif
memset(threads, 0, max_jobs * sizeof(struct thread_data));
@@
-432,8
+435,8
@@
static void copy_opt_list(struct thread_data *dst, struct thread_data *src)
/*
* Return a free job structure.
*/
/*
* Return a free job structure.
*/
-static struct thread_data *get_new_job(
int
global, struct thread_data *parent,
-
int
preserve_eo, const char *jobname)
+static struct thread_data *get_new_job(
bool
global, struct thread_data *parent,
+
bool
preserve_eo, const char *jobname)
{
struct thread_data *td;
{
struct thread_data *td;
@@
-1557,7
+1560,7
@@
static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
*/
numjobs = o->numjobs;
while (--numjobs) {
*/
numjobs = o->numjobs;
while (--numjobs) {
- struct thread_data *td_new = get_new_job(
0, td, 1
, jobname);
+ struct thread_data *td_new = get_new_job(
false, td, true
, jobname);
if (!td_new)
goto err;
if (!td_new)
goto err;
@@
-1618,11
+1621,11
@@
void add_job_opts(const char **o, int client_type)
sprintf(jobname, "%s", o[i] + 5);
}
if (in_global && !td_parent)
sprintf(jobname, "%s", o[i] + 5);
}
if (in_global && !td_parent)
- td_parent = get_new_job(
1, &def_thread, 0
, jobname);
+ td_parent = get_new_job(
true, &def_thread, false
, jobname);
else if (!in_global && !td) {
if (!td_parent)
td_parent = &def_thread;
else if (!in_global && !td) {
if (!td_parent)
td_parent = &def_thread;
- td = get_new_job(
0, td_parent, 0
, jobname);
+ td = get_new_job(
false, td_parent, false
, jobname);
}
if (in_global)
fio_options_parse(td_parent, (char **) &o[i], 1);
}
if (in_global)
fio_options_parse(td_parent, (char **) &o[i], 1);
@@
-1674,7
+1677,7
@@
static int __parse_jobs_ini(struct thread_data *td,
char *file, int is_buf, int stonewall_flag, int type,
int nested, char *name, char ***popts, int *aopts, int *nopts)
{
char *file, int is_buf, int stonewall_flag, int type,
int nested, char *name, char ***popts, int *aopts, int *nopts)
{
-
unsigned int global = 0
;
+
bool global = false
;
char *string;
FILE *f;
char *p;
char *string;
FILE *f;
char *p;
@@
-1783,7
+1786,7
@@
static int __parse_jobs_ini(struct thread_data *td,
first_sect = 0;
}
first_sect = 0;
}
- td = get_new_job(global, &def_thread,
0
, name);
+ td = get_new_job(global, &def_thread,
false
, name);
if (!td) {
ret = 1;
break;
if (!td) {
ret = 1;
break;
@@
-2323,17
+2326,22
@@
int parse_cmd_line(int argc, char *argv[], int client_type)
case 'b':
write_bw_log = 1;
break;
case 'b':
write_bw_log = 1;
break;
- case 'o':
+ case 'o': {
+ FILE *tmp;
+
if (f_out && f_out != stdout)
fclose(f_out);
if (f_out && f_out != stdout)
fclose(f_out);
- f_out = fopen(optarg, "w+");
- if (!f_out) {
- perror("fopen output");
- exit(1);
+ tmp = fopen(optarg, "w+");
+ if (!tmp) {
+ log_err("fio: output file open error: %s\n", strerror(errno));
+ exit_val = 1;
+ do_exit++;
+ break;
}
}
- f_err = f_out;
+ f_err = f_out
= tmp
;
break;
break;
+ }
case 'm':
output_format = FIO_OUTPUT_TERSE;
break;
case 'm':
output_format = FIO_OUTPUT_TERSE;
break;
@@
-2467,7
+2475,7
@@
int parse_cmd_line(int argc, char *argv[], int client_type)
if (is_section && skip_this_section(val))
continue;
if (is_section && skip_this_section(val))
continue;
- td = get_new_job(global, &def_thread,
1
, NULL);
+ td = get_new_job(global, &def_thread,
true
, NULL);
if (!td || ioengine_load(td)) {
if (td) {
put_job(td);
if (!td || ioengine_load(td)) {
if (td) {
put_job(td);
@@
-2705,7
+2713,7
@@
int parse_cmd_line(int argc, char *argv[], int client_type)
if (!ret) {
ret = add_job(td, td->o.name ?: "fio", 0, 0, client_type);
if (ret)
if (!ret) {
ret = add_job(td, td->o.name ?: "fio", 0, 0, client_type);
if (ret)
-
did_arg = 1
;
+
exit(1)
;
}
}
}
}