Remove gotos from read_iolog_get()
[fio.git] / log.c
diff --git a/log.c b/log.c
index 07ba950b9e147a5dfa98c7264fcebf660a5546d0..92bcebfcca5248961b3bf1dfa74f3240199c5089 100644 (file)
--- a/log.c
+++ b/log.c
@@ -57,40 +57,36 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
 
-restart:
-       if (!list_empty(&td->io_log_list)) {
+       while (!list_empty(&td->io_log_list)) {
                ipo = list_entry(td->io_log_list.next, struct io_piece, list);
                list_del(&ipo->list);
-               io_u->offset = ipo->offset;
-               io_u->buflen = ipo->len;
-               io_u->ddir = ipo->ddir;
-               io_u->file = ipo->file;
 
                /*
                 * invalid ddir, this is a file action
                 */
-               if (io_u->ddir == DDIR_INVAL) {
+               if (ipo->ddir == DDIR_INVAL) {
                        struct fio_file *f = &td->files[ipo->fileno];
 
                        if (ipo->file_action == FIO_LOG_OPEN_FILE) {
                                assert(!td_io_open_file(td, f));
                                free(ipo);
-                               goto restart;
+                               continue;
                        } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) {
                                td_io_close_file(td, f);
                                free(ipo);
-                               goto restart;
+                               continue;
                        }
                }
 
+               io_u->offset = ipo->offset;
+               io_u->buflen = ipo->len;
+               io_u->ddir = ipo->ddir;
+               io_u->file = &td->files[ipo->fileno];
+               get_file(io_u->file);
+
                if (ipo->delay)
                        iolog_delay(td, ipo->delay);
 
-               /*
-                * work around, this needs a format change to work for > 1 file
-                */
-               if (!io_u->file)
-                       io_u->file = &td->files[0];
                free(ipo);
                return 0;
        }