From: Jens Axboe Date: Tue, 20 Feb 2007 19:52:51 +0000 (+0100) Subject: Static error value checking X-Git-Tag: fio-1.12~48 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=b2fdda43cf0699f60e711429c778ff1685e30062;hp=948f9b2eed7aeee6367957ea30be7a2da94d5b1b Static error value checking Signed-off-by: Jens Axboe --- diff --git a/fio.c b/fio.c index 1c2748e0..95e06dd8 100644 --- a/fio.c +++ b/fio.c @@ -149,7 +149,9 @@ static void cleanup_pending_aio(struct thread_data *td) /* * get immediately available events, if any */ - io_u_queued_complete(td, 0, NULL); + r = io_u_queued_complete(td, 0, NULL); + if (r < 0) + return; /* * now cancel remaining active events @@ -165,7 +167,7 @@ static void cleanup_pending_aio(struct thread_data *td) } if (td->cur_depth) - io_u_queued_complete(td, td->cur_depth, NULL); + r = io_u_queued_complete(td, td->cur_depth, NULL); } /* @@ -203,7 +205,8 @@ requeue: return 1; } - io_u_sync_complete(td, io_u, NULL); + if (io_u_sync_complete(td, io_u, NULL) < 0) + return 1; } else if (ret == FIO_Q_BUSY) { if (td_io_commit(td)) return 1; @@ -228,10 +231,15 @@ static void do_verify(struct thread_data *td) * read from disk. */ for_each_file(td, f, i) { - fio_io_sync(td, f); - file_invalidate_cache(td, f); + if (fio_io_sync(td, f)) + break; + if (file_invalidate_cache(td, f)) + break; } + if (td->error) + return; + td_set_runstate(td, TD_VERIFYING); io_u = NULL; diff --git a/fio.h b/fio.h index 282ccf0d..e6931619 100644 --- a/fio.h +++ b/fio.h @@ -566,9 +566,9 @@ extern int init_random_state(struct thread_data *); * File setup/shutdown */ extern void close_files(struct thread_data *); -extern int setup_files(struct thread_data *); -extern int open_files(struct thread_data *); -extern int file_invalidate_cache(struct thread_data *, struct fio_file *); +extern int __must_check setup_files(struct thread_data *); +extern int __must_check open_files(struct thread_data *); +extern int __must_check file_invalidate_cache(struct thread_data *, struct fio_file *); /* * ETA/status stuff @@ -597,15 +597,15 @@ enum { * Verify helpers */ extern void populate_verify_io_u(struct thread_data *, struct io_u *); -extern int get_next_verify(struct thread_data *td, struct io_u *); -extern int verify_io_u(struct io_u *); +extern int __must_check get_next_verify(struct thread_data *td, struct io_u *); +extern int __must_check verify_io_u(struct io_u *); /* * Memory helpers */ -extern int fio_pin_memory(void); +extern int __must_check fio_pin_memory(void); extern void fio_unpin_memory(void); -extern int allocate_io_mem(struct thread_data *); +extern int __must_check allocate_io_mem(struct thread_data *); extern void free_io_mem(struct thread_data *); /* @@ -616,19 +616,19 @@ extern struct io_u *__get_io_u(struct thread_data *); extern struct io_u *get_io_u(struct thread_data *); extern void put_io_u(struct thread_data *, struct io_u *); extern void requeue_io_u(struct thread_data *, struct io_u **); -extern long io_u_sync_complete(struct thread_data *, struct io_u *, endio_handler *); -extern long io_u_queued_complete(struct thread_data *, int, endio_handler *); +extern long __must_check io_u_sync_complete(struct thread_data *, struct io_u *, endio_handler *); +extern long __must_check io_u_queued_complete(struct thread_data *, int, endio_handler *); extern void io_u_queued(struct thread_data *, struct io_u *); /* * io engine entry points */ -extern int td_io_init(struct thread_data *); -extern int td_io_prep(struct thread_data *, struct io_u *); -extern int td_io_queue(struct thread_data *, struct io_u *); -extern int td_io_sync(struct thread_data *, struct fio_file *); -extern int td_io_getevents(struct thread_data *, int, int, struct timespec *); -extern int td_io_commit(struct thread_data *); +extern int __must_check td_io_init(struct thread_data *); +extern int __must_check td_io_prep(struct thread_data *, struct io_u *); +extern int __must_check td_io_queue(struct thread_data *, struct io_u *); +extern int __must_check td_io_sync(struct thread_data *, struct fio_file *); +extern int __must_check td_io_getevents(struct thread_data *, int, int, struct timespec *); +extern int __must_check td_io_commit(struct thread_data *); /* * This is a pretty crappy semaphore implementation, but with the use that fio @@ -685,7 +685,7 @@ struct ioengine_ops { #define FIO_IOOPS_VERSION 5 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *); -extern int register_ioengine(struct ioengine_ops *); +extern void register_ioengine(struct ioengine_ops *); extern void unregister_ioengine(struct ioengine_ops *); extern void close_ioengine(struct thread_data *); diff --git a/ioengines.c b/ioengines.c index db333796..ab5b2245 100644 --- a/ioengines.c +++ b/ioengines.c @@ -66,11 +66,10 @@ void unregister_ioengine(struct ioengine_ops *ops) INIT_LIST_HEAD(&ops->list); } -int register_ioengine(struct ioengine_ops *ops) +void register_ioengine(struct ioengine_ops *ops) { INIT_LIST_HEAD(&ops->list); list_add_tail(&ops->list, &engine_list); - return 0; } static struct ioengine_ops *find_ioengine(const char *name) diff --git a/os.h b/os.h index a2699dd2..da80fbd4 100644 --- a/os.h +++ b/os.h @@ -54,4 +54,10 @@ #define FIO_HUGE_PAGE (4096 * 1024) #endif +#if __GNUC__ < 3 +#define __must_check +#else +#define __must_check __attribute__((warn_unused_result)) +#endif + #endif