From: Jens Axboe Date: Tue, 16 Aug 2016 05:36:11 +0000 (-0600) Subject: Various cleanups X-Git-Tag: fio-2.14~31 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=8aa89d70f44eb3fe9d9581fd9bcc3cebca22621b Various cleanups - Killing unused declarations - Bool - Making code static Signed-off-by: Jens Axboe --- diff --git a/client.c b/client.c index d502a4b3..238c93fc 100644 --- a/client.c +++ b/client.c @@ -557,7 +557,7 @@ int fio_client_terminate(struct fio_client *client) return fio_net_send_quit(client->fd); } -void fio_clients_terminate(void) +static void fio_clients_terminate(void) { struct flist_head *entry; struct fio_client *client; diff --git a/client.h b/client.h index c59b89b5..fc9c1969 100644 --- a/client.h +++ b/client.h @@ -131,7 +131,6 @@ extern struct fio_client *fio_client_add_explicit(struct client_ops *, const cha extern void fio_client_add_cmd_option(void *, const char *); extern int fio_client_add_ini_file(void *, const char *, bool); extern int fio_client_terminate(struct fio_client *); -extern void fio_clients_terminate(void); extern struct fio_client *fio_get_client(struct fio_client *); extern void fio_put_client(struct fio_client *); extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *); diff --git a/eta.c b/eta.c index ffab34e2..3c1aeeee 100644 --- a/eta.c +++ b/eta.c @@ -337,7 +337,7 @@ static void calc_iops(int unified_rw_rep, unsigned long mtime, * Print status of the jobs we know about. This includes rate estimates, * ETA, thread state, etc. */ -int calc_thread_status(struct jobs_eta *je, int force) +bool calc_thread_status(struct jobs_eta *je, int force) { struct thread_data *td; int i, unified_rw_rep; @@ -354,12 +354,12 @@ int calc_thread_status(struct jobs_eta *je, int force) if (!force) { if (!(output_format & FIO_OUTPUT_NORMAL) && f_out == stdout) - return 0; + return false; if (temp_stall_ts || eta_print == FIO_ETA_NEVER) - return 0; + return false; if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS)) - return 0; + return false; } if (!ddir_rw_sum(rate_io_bytes)) @@ -479,7 +479,7 @@ int calc_thread_status(struct jobs_eta *je, int force) * Allow a little slack, the target is to print it every 1000 msecs */ if (!force && disp_time < 900) - return 0; + return false; calc_rate(unified_rw_rep, disp_time, io_bytes, disp_io_bytes, je->rate); calc_iops(unified_rw_rep, disp_time, io_iops, disp_io_iops, je->iops); @@ -487,12 +487,12 @@ int calc_thread_status(struct jobs_eta *je, int force) memcpy(&disp_prev_time, &now, sizeof(now)); if (!force && !je->nr_running && !je->nr_pending) - return 0; + return false; je->nr_threads = thread_number; update_condensed_str(__run_str, run_str); memcpy(je->run_str, run_str, strlen(run_str)); - return 1; + return true; } void display_thread_status(struct jobs_eta *je) diff --git a/file.h b/file.h index 0cf622fc..f7e5d204 100644 --- a/file.h +++ b/file.h @@ -209,7 +209,7 @@ extern void dup_files(struct thread_data *, struct thread_data *); extern int get_fileno(struct thread_data *, const char *); extern void free_release_files(struct thread_data *); extern void filesetup_mem_free(void); -void fio_file_reset(struct thread_data *, struct fio_file *); -int fio_files_done(struct thread_data *); +extern void fio_file_reset(struct thread_data *, struct fio_file *); +extern int fio_files_done(struct thread_data *); #endif diff --git a/fio.h b/fio.h index e96a4dd1..0da0bc5d 100644 --- a/fio.h +++ b/fio.h @@ -451,7 +451,6 @@ extern int read_only; extern int eta_print; extern int eta_new_line; extern unsigned long done_secs; -extern char *job_section; extern int fio_gtod_offload; extern int fio_gtod_cpu; extern enum fio_cs fio_clock_source; @@ -514,7 +513,7 @@ extern void td_fill_verify_state_seed(struct thread_data *); extern void add_job_opts(const char **, int); extern char *num2str(uint64_t, int, int, int, int); extern int ioengine_load(struct thread_data *); -extern int parse_dryrun(void); +extern bool parse_dryrun(void); extern int fio_running_or_pending_io_threads(void); extern int fio_set_fd_nonblocking(int, const char *); extern void sig_show_status(int sig); @@ -643,17 +642,17 @@ extern void lat_target_reset(struct thread_data *); } \ } while (0) -static inline int fio_fill_issue_time(struct thread_data *td) +static inline bool fio_fill_issue_time(struct thread_data *td) { if (td->o.read_iolog_file || !td->o.disable_clat || !td->o.disable_slat || !td->o.disable_bw) - return 1; + return true; - return 0; + return false; } -static inline int __should_check_rate(struct thread_data *td, - enum fio_ddir ddir) +static inline bool __should_check_rate(struct thread_data *td, + enum fio_ddir ddir) { struct thread_options *o = &td->o; @@ -662,23 +661,21 @@ static inline int __should_check_rate(struct thread_data *td, */ if (o->rate[ddir] || o->ratemin[ddir] || o->rate_iops[ddir] || o->rate_iops_min[ddir]) - return 1; + return true; - return 0; + return false; } -static inline int should_check_rate(struct thread_data *td) +static inline bool should_check_rate(struct thread_data *td) { - int ret = 0; - - if (td->bytes_done[DDIR_READ]) - ret |= __should_check_rate(td, DDIR_READ); - if (td->bytes_done[DDIR_WRITE]) - ret |= __should_check_rate(td, DDIR_WRITE); - if (td->bytes_done[DDIR_TRIM]) - ret |= __should_check_rate(td, DDIR_TRIM); - - return ret; + if (td->bytes_done[DDIR_READ] && __should_check_rate(td, DDIR_READ)) + return true; + if (td->bytes_done[DDIR_WRITE] && __should_check_rate(td, DDIR_WRITE)) + return true; + if (td->bytes_done[DDIR_TRIM] && __should_check_rate(td, DDIR_TRIM)) + return true; + + return false; } static inline unsigned int td_max_bs(struct thread_data *td) diff --git a/gclient.c b/gclient.c index 84bb6a4c..23b08993 100644 --- a/gclient.c +++ b/gclient.c @@ -1008,7 +1008,7 @@ static void gfio_show_lat(GtkWidget *vbox, const char *name, unsigned long min, char *minp, *maxp; char tmp[64]; - if (!usec_to_msec(&min, &max, &mean, &dev)) + if (usec_to_msec(&min, &max, &mean, &dev)) base = "(msec)"; minp = num2str(min, 6, 1, 0, 0); diff --git a/init.c b/init.c index 8c8101c6..5ff73859 100644 --- a/init.c +++ b/init.c @@ -1247,7 +1247,7 @@ static char *make_filename(char *buf, size_t buf_size,struct thread_options *o, return buf; } -int parse_dryrun(void) +bool parse_dryrun(void) { return dump_cmdline || parse_only; } diff --git a/iolog.h b/iolog.h index 011179a0..93e970e5 100644 --- a/iolog.h +++ b/iolog.h @@ -109,10 +109,11 @@ struct io_log { unsigned long avg_msec; unsigned long avg_last; - /* - * Windowed latency histograms, for keeping track of when we need to - * save a copy of the histogram every approximately hist_msec milliseconds. - */ + /* + * Windowed latency histograms, for keeping track of when we need to + * save a copy of the histogram every approximately hist_msec + * milliseconds. + */ struct io_hist hist_window[DDIR_RWDIR_CNT]; unsigned long hist_msec; int hist_coarseness; diff --git a/options.h b/options.h index 874141dc..83a58e27 100644 --- a/options.h +++ b/options.h @@ -17,7 +17,6 @@ void add_opt_posval(const char *, const char *, const char *); void del_opt_posval(const char *, const char *); struct thread_data; void fio_options_free(struct thread_data *); -char *get_name_idx(char *, int); int set_name_idx(char *, size_t, char *, int, bool); extern char client_sockaddr_str[]; /* used with --client option */ diff --git a/parse.c b/parse.c index 086f7864..8ed4619e 100644 --- a/parse.c +++ b/parse.c @@ -1250,7 +1250,7 @@ void fill_default_options(void *data, struct fio_option *options) handle_option(o, o->def, data); } -void option_init(struct fio_option *o) +static void option_init(struct fio_option *o) { if (o->type == FIO_OPT_DEPRECATED || o->type == FIO_OPT_UNSUPPORTED) return; diff --git a/parse.h b/parse.h index 0da7c7e5..d852ddc9 100644 --- a/parse.h +++ b/parse.h @@ -85,7 +85,6 @@ extern void sort_options(char **, struct fio_option *, int); extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *, struct flist_head *); extern int show_cmd_help(struct fio_option *, const char *); extern void fill_default_options(void *, struct fio_option *); -extern void option_init(struct fio_option *); extern void options_init(struct fio_option *); extern void options_free(struct fio_option *, void *); diff --git a/stat.c b/stat.c index d0eaa477..6f5f002b 100644 --- a/stat.c +++ b/stat.c @@ -257,13 +257,13 @@ out: free(ovals); } -int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, - double *mean, double *dev) +bool calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, + double *mean, double *dev) { double n = (double) is->samples; if (n == 0) - return 0; + return false; *min = is->min_val; *max = is->max_val; @@ -274,7 +274,7 @@ int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, else *dev = 0; - return 1; + return true; } void show_group_stats(struct group_run_stats *rs, struct buf_output *out) @@ -364,7 +364,7 @@ static void display_lat(const char *name, unsigned long min, unsigned long max, const char *base = "(usec)"; char *minp, *maxp; - if (!usec_to_msec(&min, &max, &mean, &dev)) + if (usec_to_msec(&min, &max, &mean, &dev)) base = "(msec)"; minp = num2str(min, 6, 1, 0, 0); diff --git a/stat.h b/stat.h index 86f1a0b5..c3e343d2 100644 --- a/stat.h +++ b/stat.h @@ -249,7 +249,7 @@ extern void stat_exit(void); extern struct json_object * show_thread_status(struct thread_stat *ts, struct group_run_stats *rs, struct flist_head *, struct buf_output *); extern void show_group_stats(struct group_run_stats *rs, struct buf_output *); -extern int calc_thread_status(struct jobs_eta *je, int force); +extern bool calc_thread_status(struct jobs_eta *je, int force); extern void display_thread_status(struct jobs_eta *je); extern void show_run_stats(void); extern void __show_run_stats(void); @@ -261,7 +261,7 @@ extern void sum_group_stats(struct group_run_stats *dst, struct group_run_stats extern void init_thread_stat(struct thread_stat *ts); extern void init_group_run_stat(struct group_run_stats *gs); extern void eta_to_str(char *str, unsigned long eta_sec); -extern int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, double *mean, double *dev); +extern bool calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, double *mean, double *dev); extern unsigned int calc_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, fio_fp64_t *plist, unsigned int **output, unsigned int *maxv, unsigned int *minv); extern void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat); extern void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat); @@ -286,18 +286,18 @@ extern int calc_log_samples(void); extern struct io_log *agg_io_log[DDIR_RWDIR_CNT]; extern int write_bw_log; -static inline int usec_to_msec(unsigned long *min, unsigned long *max, - double *mean, double *dev) +static inline bool usec_to_msec(unsigned long *min, unsigned long *max, + double *mean, double *dev) { if (*min > 1000 && *max > 1000 && *mean > 1000.0 && *dev > 1000.0) { *min /= 1000; *max /= 1000; *mean /= 1000.0; *dev /= 1000.0; - return 0; + return true; } - return 1; + return false; } /* * Worst level condensing would be 1:5, so allow enough room for that