fio: Some minor code cleanups
authorAvri Altman <avri.altman@wdc.com>
Tue, 5 Mar 2024 09:00:04 +0000 (11:00 +0200)
committerVincent Fu <vincent.fu@samsung.com>
Tue, 5 Mar 2024 15:54:36 +0000 (10:54 -0500)
limit the scope of variables when possible, fix style isses etc.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240305090008.1216-2-avri.altman@wdc.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
HOWTO.rst
backend.c
eta.c
io_u.c
parse.h
stat.h

index 169cdc2a01510a068bffbb7b77ef50b8db47ac77..c404d724aa8e92906f713108ddc76fc5376e1795 100644 (file)
--- a/HOWTO.rst
+++ b/HOWTO.rst
@@ -2786,7 +2786,7 @@ with the caveat that when used on the command line, they must come after the
 
 .. option:: sg_write_mode=str : [sg]
 
-       Specify the type of write commands to issue. This option can take three values:
+       Specify the type of write commands to issue. This option can take ten values:
 
        **write**
                This is the default where write opcodes are issued as usual.
index 2f2221bf9c6398920628897e82da7d14f1650f36..fb7dc68a92084962b3f522741810452a098aa216 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -2094,14 +2094,14 @@ static void reap_threads(unsigned int *nr_running, uint64_t *t_rate,
                         uint64_t *m_rate)
 {
        unsigned int cputhreads, realthreads, pending;
-       int status, ret;
+       int ret;
 
        /*
         * reap exited threads (TD_EXITED -> TD_REAPED)
         */
        realthreads = pending = cputhreads = 0;
        for_each_td(td) {
-               int flags = 0;
+               int flags = 0, status;
 
                if (!strcmp(td->o.ioengine, "cpuio"))
                        cputhreads++;
diff --git a/eta.c b/eta.c
index cc3424613e360d5df1659d2cf86fccaf93de2f22..7d07708ff69ee9701fe3ce4f3e8a1e95e91311e8 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -215,8 +215,9 @@ static unsigned long thread_eta(struct thread_data *td)
                                perc = td->o.rwmix[DDIR_WRITE];
 
                        bytes_total += (bytes_total * perc) / 100;
-               } else
+               } else {
                        bytes_total <<= 1;
+               }
        }
 
        if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) {
@@ -228,8 +229,9 @@ static unsigned long thread_eta(struct thread_data *td)
                        perc = (double) bytes_done / (double) bytes_total;
                        if (perc > 1.0)
                                perc = 1.0;
-               } else
+               } else {
                        perc = 0.0;
+               }
 
                if (td->o.time_based) {
                        if (timeout) {
@@ -395,7 +397,7 @@ static bool skip_eta()
  * Print status of the jobs we know about. This includes rate estimates,
  * ETA, thread state, etc.
  */
-bool calc_thread_status(struct jobs_eta *je, int force)
+static bool calc_thread_status(struct jobs_eta *je, int force)
 {
        int unified_rw_rep;
        bool any_td_in_ramp;
diff --git a/io_u.c b/io_u.c
index 2b8e17f8433684a8aba2fd8b53ee8b342d8a931f..09e5f15a8b1ffe785adcd546da1e8232c9f47399 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1895,8 +1895,9 @@ struct io_u *get_io_u(struct thread_data *td)
                                        io_u->buflen);
                        } else if ((td->flags & TD_F_SCRAMBLE_BUFFERS) &&
                                   !(td->flags & TD_F_COMPRESS) &&
-                                  !(td->flags & TD_F_DO_VERIFY))
+                                  !(td->flags & TD_F_DO_VERIFY)) {
                                do_scramble = 1;
+                       }
                } else if (io_u->ddir == DDIR_READ) {
                        /*
                         * Reset the buf_filled parameters so next time if the
diff --git a/parse.h b/parse.h
index d68484eaf0c65572352222297162ebd0d20cf7e7..806a76ee09eee1ba4ad1978b542a4e8b8ed2bc37 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -32,7 +32,7 @@ enum fio_opt_type {
  */
 struct value_pair {
        const char *ival;               /* string option */
-       unsigned long long oval;/* output value */
+       unsigned long long oval;        /* output value */
        const char *help;               /* help text for sub option */
        int orval;                      /* OR value */
        void *cb;                       /* sub-option callback */
diff --git a/stat.h b/stat.h
index bd986d4e71c9b7f1b9b42174df33076143396f65..0d57cceb217543e596364cfeeefd75edad142dbd 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -345,7 +345,6 @@ 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 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 int __show_running_run_stats(void);