summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Price <anprice@redhat.com>2014-04-26 02:56:17 +0100
committerChris Mason <clm@fb.com>2014-09-24 12:02:09 -0700
commitc9e749da1b973efddc75ca4d66b9c662ab81b42b (patch)
tree6995cb60c03557f70951c1c1fbbfa3070abd8a81
parentd6b58e52984f6c53958266b09baa5360cf7cbb62 (diff)
downloadblktrace-c9e749da1b973efddc75ca4d66b9c662ab81b42b.tar.gz
blktrace-c9e749da1b973efddc75ca4d66b9c662ab81b42b.tar.bz2
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>
-rw-r--r--iowatcher/main.c21
-rw-r--r--iowatcher/tracers.h1
2 files changed, 6 insertions, 16 deletions
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