From: Jens Axboe Date: Fri, 6 Dec 2013 19:02:10 +0000 (-0700) Subject: Calloc() cleanup X-Git-Tag: fio-2.1.5~46 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=572cfb3f4d2cbf22291b395f2bb41facdc17ce86 Calloc() cleanup Signed-off-by: Jens Axboe --- diff --git a/gettime.c b/gettime.c index 1a0f8274..277f2cf8 100644 --- a/gettime.c +++ b/gettime.c @@ -327,7 +327,7 @@ void fio_local_clock_init(int is_thread) { struct tv_valid *t; - t = calloc(sizeof(*t), 1); + t = calloc(1, sizeof(*t)); if (pthread_setspecific(tv_tls_key, t)) log_err("fio: can't set TLS key\n"); } diff --git a/io_u_queue.c b/io_u_queue.c index 5734e9c3..80a32ba3 100644 --- a/io_u_queue.c +++ b/io_u_queue.c @@ -3,7 +3,7 @@ int io_u_qinit(struct io_u_queue *q, unsigned int nr) { - q->io_us = calloc(sizeof(struct io_u *), nr); + q->io_us = calloc(nr, sizeof(struct io_u *)); if (!q->io_us) return 1; @@ -29,7 +29,7 @@ int io_u_rinit(struct io_u_ring *ring, unsigned int nr) ring->max++; } - ring->ring = calloc(sizeof(struct io_u *), ring->max); + ring->ring = calloc(ring->max, sizeof(struct io_u *)); if (!ring->ring) return 1; diff --git a/profiles/act.c b/profiles/act.c index 73cde856..7e2f8af1 100644 --- a/profiles/act.c +++ b/profiles/act.c @@ -389,7 +389,7 @@ static void put_act_ref(struct thread_data *td) fio_mutex_down(act_run_data->mutex); if (!act_run_data->slices) { - act_run_data->slices = calloc(sizeof(struct act_slice), apd->nr_slices); + act_run_data->slices = calloc(apd->nr_slices, sizeof(struct act_slice)); act_run_data->nr_slices = apd->nr_slices; } @@ -416,9 +416,9 @@ static int act_td_init(struct thread_data *td) get_act_ref(); - apd = calloc(sizeof(*apd), 1); + apd = calloc(1, sizeof(*apd)); nr_slices = (test_duration + SAMPLE_SEC - 1) / SAMPLE_SEC; - apd->slices = calloc(sizeof(struct act_slice), nr_slices); + apd->slices = calloc(nr_slices, sizeof(struct act_slice)); apd->nr_slices = nr_slices; fio_gettime(&apd->sample_tv, NULL); td->prof_data = apd; @@ -452,7 +452,7 @@ static struct profile_ops act_profile = { static void fio_init act_register(void) { - act_run_data = calloc(sizeof(*act_run_data), 1); + act_run_data = calloc(1, sizeof(*act_run_data)); act_run_data->mutex = fio_mutex_init(FIO_MUTEX_UNLOCKED); if (register_profile(&act_profile))