From: Jens Axboe Date: Thu, 26 Apr 2018 20:44:18 +0000 (-0600) Subject: iolog: always use calloc() and always init both lists X-Git-Tag: fio-3.7~16 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=8812d7f2a3a719acd71e6dcd9a3ef25607cfb6ef iolog: always use calloc() and always init both lists Signed-off-by: Jens Axboe --- diff --git a/blktrace.c b/blktrace.c index 721bcd4b..29d1ff74 100644 --- a/blktrace.c +++ b/blktrace.c @@ -222,8 +222,9 @@ static void store_ipo(struct thread_data *td, unsigned long long offset, unsigned int bytes, int rw, unsigned long long ttime, int fileno, unsigned int bs) { - struct io_piece *ipo = malloc(sizeof(*ipo)); + struct io_piece *ipo; + ipo = calloc(1, sizeof(*ipo)); init_ipo(ipo); ipo->offset = offset * bs; @@ -268,10 +269,11 @@ static void handle_trace_discard(struct thread_data *td, unsigned long long ttime, unsigned long *ios, unsigned int *rw_bs) { - struct io_piece *ipo = malloc(sizeof(*ipo)); + struct io_piece *ipo; unsigned int bs; int fileno; + ipo = calloc(1, sizeof(*ipo)); init_ipo(ipo); fileno = trace_add_file(td, t->device, &bs); diff --git a/iolog.c b/iolog.c index 74c89f0c..f1e52311 100644 --- a/iolog.c +++ b/iolog.c @@ -211,7 +211,7 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u) struct fio_rb_node **p, *parent; struct io_piece *ipo, *__ipo; - ipo = malloc(sizeof(struct io_piece)); + ipo = calloc(1, sizeof(struct io_piece)); init_ipo(ipo); ipo->file = io_u->file; ipo->offset = io_u->offset; @@ -440,7 +440,7 @@ static int read_iolog2(struct thread_data *td, FILE *f) /* * Make note of file */ - ipo = malloc(sizeof(*ipo)); + ipo = calloc(1, sizeof(*ipo)); init_ipo(ipo); ipo->ddir = rw; if (rw == DDIR_WAIT) { diff --git a/iolog.h b/iolog.h index f70eb61e..d689140f 100644 --- a/iolog.h +++ b/iolog.h @@ -296,7 +296,7 @@ extern int iolog_cur_flush(struct io_log *, struct io_logs *); static inline void init_ipo(struct io_piece *ipo) { - memset(ipo, 0, sizeof(*ipo)); + INIT_FLIST_HEAD(&ipo->list); INIT_FLIST_HEAD(&ipo->trim_list); }