Various cleanups
authorJens Axboe <axboe@fb.com>
Tue, 16 Aug 2016 05:36:11 +0000 (23:36 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 16 Aug 2016 05:36:11 +0000 (23:36 -0600)
- Killing unused declarations

- Bool

- Making code static

Signed-off-by: Jens Axboe <axboe@fb.com>
13 files changed:
client.c
client.h
eta.c
file.h
fio.h
gclient.c
init.c
iolog.h
options.h
parse.c
parse.h
stat.c
stat.h

index d502a4b34d4c57a060d96f3c24d4436f4a0bf9bb..238c93fc862e15ace97aa66e7358f4b07a0fe0ea 100644 (file)
--- 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;
index c59b89b5730cf2c96a48bf2df56d543dca70bd9c..fc9c19693a9ff0c60bfcee6429755344b72cdfdf 100644 (file)
--- 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 ffab34e2c740c8d38ac3c808a062013f6c0c1abd..3c1aeeee98cbd0cb0d3dcbe35f7c1287d7a39450 100644 (file)
--- 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 0cf622fcbb213a7922ecb96a8e7b7f88bd76b2f2..f7e5d2046a3e98cbce18ae94665a4318215c0dec 100644 (file)
--- 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 e96a4dd1dcd1058071e20502d58003be38e88dae..0da0bc5d97442544d2b2269b32c7b8ae64c79ba3 100644 (file)
--- 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)
index 84bb6a4ccbb05534e6bd8d0c90933683b7fac63d..23b0899322052f20744c149561351829325169f1 100644 (file)
--- 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 8c8101c629d46672b81202a675bbce33720825e6..5ff73859d50d444ed371c33a36c710182aa0bb38 100644 (file)
--- 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 011179a020ccd05830be26ca1d82053417623f32..93e970e5f294e7185068bca259613d77f0108171 100644 (file)
--- 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;
index 874141dcd29c4208e93ebb6914747765951f1a9f..83a58e27d50718ba91d909795aec5f419440ca2a 100644 (file)
--- 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 086f7864b8b6eb16ee0aa6527e86a32079833bfd..8ed4619e6e08f765b783e3c59f3bf7b5632faf2d 100644 (file)
--- 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 0da7c7e5852e47aafd0fd274717f9930cd1c1505..d852ddc9292391e02e1239a5afbfedf14265589b 100644 (file)
--- 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 d0eaa477cc6625580fa348c99ecdaefabeae1169..6f5f002b487aab90601ac5e5985ae886d8b728d1 100644 (file)
--- 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 86f1a0b5f91af45af3288b7b37ba74ec84efec79..c3e343d2de2ff5f743b36d8b00cd101c0ee4ed04 100644 (file)
--- 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