Signed-off-by: Vincent Guittot vincent.guittot@linaro.org --- src/rt-app.c | 20 ++++++++------------ src/rt-app_args.c | 7 ++++--- src/rt-app_parse_config.c | 7 ++++--- 3 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/rt-app.c b/src/rt-app.c index a7c1d97..3515027 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -474,8 +474,7 @@ int main(int argc, char* argv[]) clock_gettime(CLOCK_MONOTONIC, &t_start);
/* start threads */ - for (i = 0; i < nthreads; i++) - { + for (i = 0; i < nthreads; i++) { tdata = &opts.threads_data[i]; if (opts.spacing > 0 ) { /* start the thread, then it will sleep accordingly @@ -500,7 +499,7 @@ int main(int argc, char* argv[]) opts.logbasename, tdata->name); tdata->log_handler = fopen(tmp, "w"); - if (!tdata->log_handler){ + if (!tdata->log_handler) { log_error("Cannot open logfile %s", tmp); exit(EXIT_FAILURE); } @@ -516,8 +515,7 @@ int main(int argc, char* argv[]) }
/* print gnuplot files */ - if (opts.logdir && opts.gnuplot) - { + if (opts.logdir && opts.gnuplot) { snprintf(tmp, PATH_LENGTH, "%s/%s-duration.plot", opts.logdir, opts.logbasename); gnuplot_script = fopen(tmp, "w+"); @@ -533,8 +531,7 @@ int main(int argc, char* argv[]) "set ylabel "Exec Time [usec]"\n" "plot ", tmp);
- for (i=0; i<nthreads; i++) - { + for (i=0; i<nthreads; i++) { snprintf(tmp, PATH_LENGTH, "%s/%s-duration.plot", opts.logdir, opts.logbasename);
@@ -570,8 +567,7 @@ int main(int argc, char* argv[]) "set ylabel "Slack/Tardiness [usec]"\n" "plot ", tmp);
- for (i=0; i < nthreads; i++) - { + for (i=0; i < nthreads; i++) { fprintf(gnuplot_script, ""%s-%s.log" u ($5/1000):10 w l" " title "thread [%s] (%s)"", @@ -585,19 +581,19 @@ int main(int argc, char* argv[]) fprintf(gnuplot_script, ", ");
} + fprintf(gnuplot_script, "set terminal wxt\nreplot\n"); fclose(gnuplot_script); }
- if (opts.duration > 0) - { + if (opts.duration > 0) { sleep(opts.duration); if (opts.ftrace) log_ftrace(ft_data.marker_fd, "main shutdown\n"); shutdown(SIGTERM); }
- for (i = 0; i < nthreads; i++) { + for (i = 0; i < nthreads; i++) { pthread_join(threads[i], NULL); }
diff --git a/src/rt-app_args.c b/src/rt-app_args.c index cda1034..fa2c646 100644 --- a/src/rt-app_args.c +++ b/src/rt-app_args.c @@ -354,14 +354,15 @@ void parse_command_line(int argc, char **argv, rtapp_options_t *opts) { #ifdef JSON + struct stat config_file_stat; + if (argc < 2) usage(NULL, EXIT_SUCCESS); - struct stat config_file_stat; + if (stat(argv[1], &config_file_stat) == 0) { parse_config(argv[1], opts); return; - } - else if (strcmp(argv[1], "-") == 0) { + } else if (strcmp(argv[1], "-") == 0) { parse_config_stdin(opts); return; } diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index fde6f9e..85aa14f 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -260,10 +260,11 @@ parse_thread_resources(const rtapp_options_t *opts, struct json_object *locks, rtapp_resource_access_list_t *tmp, *head, *last; char debug_msg[512], tmpmsg[512];
- data->blockages = malloc(sizeof(rtapp_tasks_resource_list_t) * - json_object_array_length(locks)); data->nblockages = json_object_array_length(locks); - for (i = 0; i< json_object_array_length(locks); i++) + data->blockages = malloc(sizeof(rtapp_tasks_resource_list_t) * + data->nblockages); + + for (i = 0; i< data->nblockages; i++) { res = json_object_array_get_idx(locks, i); if (!json_object_is_type(res, json_type_int)){