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 <anprice@redhat.com>
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 @@
}
}
-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 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 @@
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 @@
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 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