From: Andrew Price Date: Sat, 26 Apr 2014 01:56:17 +0000 (+0100) Subject: iowatcher: Simplify temp movie directory creation X-Git-Tag: blktrace-1.1.0~2^2~9 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=c9e749da1b973efddc75ca4d66b9c662ab81b42b;p=blktrace.git iowatcher: Simplify temp movie directory creation plot_io_movie() was calling create_movie_temp_dir() which unnecessarily strdup()ed a string constant leaving plot_io_movie() to free it. Replace the strdup() with a mutable char array and get rid of the free(). Merge the few remaining lines which create the movie dir into plot_io_movie(). Also prune a duplicate declaration of start_mpstat() in tracers.h Signed-off-by: Andrew Price --- diff --git a/iowatcher/main.c b/iowatcher/main.c index 5cbfa53..92b0ef3 100644 --- a/iowatcher/main.c +++ b/iowatcher/main.c @@ -569,19 +569,6 @@ again: } } -static char *create_movie_temp_dir(void) -{ - char *ret; - char *pattern = strdup("io-movie-XXXXXX");; - - ret = mkdtemp(pattern); - if (!ret) { - perror("Unable to create temp directory for movie files"); - exit(1); - } - return ret; -} - static struct pid_plot_history *alloc_pid_plot_history(char *color) { struct pid_plot_history *pph; @@ -1080,7 +1067,6 @@ static void cleanup_movie(char *movie_dir) static void plot_io_movie(struct plot *plot) { struct trace_file *tf; - char *movie_dir = create_movie_temp_dir(); int i, pid; struct plot_history *history; int batch_i; @@ -1091,6 +1077,12 @@ static void plot_io_movie(struct plot *plot) int batch_count; int graph_width_factor = 5; int orig_y_offset; + char movie_dir[] = "io-movie-XXXXXX"; + + if (mkdtemp(movie_dir) == NULL) { + perror("Unable to create temp directory for movie files"); + exit(1); + } get_graph_size(&cols, &rows); batch_count = cols / total_frames; @@ -1194,7 +1186,6 @@ static void plot_io_movie(struct plot *plot) convert_movie_files(movie_dir); encode_movie(movie_dir); cleanup_movie(movie_dir); - free(movie_dir); } static void plot_latency(struct plot *plot, unsigned int min_seconds, diff --git a/iowatcher/tracers.h b/iowatcher/tracers.h index 92f349a..0db19b4 100644 --- a/iowatcher/tracers.h +++ b/iowatcher/tracers.h @@ -23,7 +23,6 @@ int stop_blktrace(void); int start_blktrace(char **devices, int num_devices, char *trace_name, char *dest); int start_mpstat(char *trace_name); int wait_for_tracers(void); -int start_mpstat(char *trace_name); #endif