Allocate thread_stat name arrays statically
authorJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:21:25 +0000 (12:21 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:21:25 +0000 (12:21 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.h
stat.c

diff --git a/fio.h b/fio.h
index d540645..1d3a9d4 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -170,15 +170,17 @@ enum {
 #define FIO_IO_U_LIST_MAX_LEN 20 /* The size of the default and user-specified
                                        list of percentiles */
 
-#define MAX_PATTERN_SIZE 512
+#define MAX_PATTERN_SIZE       512
+#define FIO_JOBNAME_SIZE       128
+#define FIO_VERROR_SIZE                128
 
 struct thread_stat {
-       char *name;
-       char *verror;
+       char name[FIO_JOBNAME_SIZE];
+       char verror[FIO_VERROR_SIZE];
        int32_t error;
        int32_t groupid;
        uint32_t pid;
-       char *description;
+       char description[FIO_JOBNAME_SIZE];
        uint32_t members;
 
        /*
@@ -409,8 +411,6 @@ struct thread_options {
        unsigned int userspace_libaio_reap;
 };
 
-#define FIO_VERROR_SIZE        128
-
 /*
  * This describes a single thread/process executing a fio job.
  */
diff --git a/stat.c b/stat.c
index 4bae576..564edf3 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -727,8 +727,9 @@ void show_run_stats(void)
                        /*
                         * These are per-group shared already
                         */
-                       ts->name = td->o.name;
-                       ts->description = td->o.description;
+                       strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE);
+                       strncpy(ts->description, td->o.description,
+                                       FIO_JOBNAME_SIZE);
                        ts->groupid = td->groupid;
 
                        /*
@@ -750,10 +751,10 @@ void show_run_stats(void)
                        if (!td->error && td->o.continue_on_error &&
                            td->first_error) {
                                ts->error = td->first_error;
-                               ts->verror = td->verror;
+                               strcpy(ts->verror, td->verror);
                        } else  if (td->error) {
                                ts->error = td->error;
-                               ts->verror = td->verror;
+                               strcpy(ts->verror, td->verror);
                        }
                }