steadystate: Use calloc(3)
[fio.git] / steadystate.c
index bce35b9718f237512597cba8a7710d890d705280..43c715c96422dddfcbca6f8fed9871c80ee4ffd2 100644 (file)
@@ -8,13 +8,8 @@ bool steadystate_enabled = false;
 
 static void steadystate_alloc(struct thread_data *td)
 {
-       int i;
-
-       td->ss.bw_data = malloc(td->ss.dur * sizeof(uint64_t));
-       td->ss.iops_data = malloc(td->ss.dur * sizeof(uint64_t));
-       /* initialize so that it is obvious if the cache is not full in the output */
-       for (i = 0; i < td->ss.dur; i++)
-               td->ss.iops_data[i] = td->ss.bw_data[i] = 0;
+       td->ss.bw_data = calloc(td->ss.dur, sizeof(uint64_t));
+       td->ss.iops_data = calloc(td->ss.dur, sizeof(uint64_t));
 
        td->ss.state |= __FIO_SS_DATA;
 }
@@ -278,7 +273,7 @@ void steadystate_check(void)
                                        (unsigned long long) group_bw,
                                        ss->head, ss->tail);
 
-               if (td->o.ss & __FIO_SS_SLOPE)
+               if (ss->state & __FIO_SS_SLOPE)
                        ret = steadystate_slope(group_iops, group_bw, td);
                else
                        ret = steadystate_deviation(group_iops, group_bw, td);
@@ -317,7 +312,7 @@ int td_steadystate_init(struct thread_data *td)
                ss->limit = o->ss_limit.u.f;
                ss->ramp_time = o->ss_ramp_time;
 
-               ss->state = o->ss;
+               ss->state = o->ss_state;
                if (!td->ss.ramp_time)
                        ss->state |= __FIO_SS_RAMP_OVER;