From 66cae656d1c546356fe60a5cb73ec80bf1eb969f Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Mon, 28 Aug 2023 15:20:51 +0100 Subject: [PATCH] Rename state variable "no_op" to the more descriptive "no_display", as pv is not doing nothing when this is set, it is still transferring data. --- src/include/options.h | 2 +- src/include/pv-internal.h | 2 +- src/include/pv.h | 2 +- src/main/main.c | 6 +++--- src/main/options.c | 2 +- src/pv/loop.c | 4 ++-- src/pv/state.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/include/options.h b/src/include/options.h index a06fdf4..33f6e26 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -35,7 +35,7 @@ struct opts_s { /* structure describing run-time options */ bool wait; /* wait for transfer before display */ bool linemode; /* count lines instead of bytes */ bool null; /* lines are null-terminated */ - bool no_op; /* do nothing other than pipe data */ + bool no_display; /* do nothing other than pipe data */ unsigned long long rate_limit; /* rate limit, in bytes per second */ unsigned long long buffer_size;/* buffer size, in bytes (0=default) */ unsigned int remote; /* PID of pv to update settings of */ diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index 3fbe010..4a8d988 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -90,7 +90,7 @@ struct pvstate_s { bool linemode; /* count lines instead of bytes */ bool bits; /* report bits instead of bytes */ bool null; /* lines are null-terminated */ - bool no_op; /* do nothing other than pipe data */ + bool no_display; /* do nothing other than pipe data */ unsigned int skip_errors; /* skip read errors counter */ bool stop_at_size; /* set if we stop at "size" bytes */ bool sync_after_write; /* set if we sync after every write */ diff --git a/src/include/pv.h b/src/include/pv.h index ed474b0..da28249 100644 --- a/src/include/pv.h +++ b/src/include/pv.h @@ -108,7 +108,7 @@ extern void pv_state_delay_start_set(pvstate_t, double); extern void pv_state_linemode_set(pvstate_t, bool); extern void pv_state_bits_set(pvstate_t, bool); extern void pv_state_null_set(pvstate_t, bool); -extern void pv_state_no_op_set(pvstate_t, bool); +extern void pv_state_no_display_set(pvstate_t, bool); extern void pv_state_skip_errors_set(pvstate_t, unsigned int); extern void pv_state_stop_at_size_set(pvstate_t, bool); extern void pv_state_sync_after_write_set(pvstate_t, bool); diff --git a/src/main/main.c b/src/main/main.c index 4622ea0..356b0f0 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -211,8 +211,8 @@ int main(int argc, char **argv) if ((0 == isatty(STDERR_FILENO)) && (false == opts->force) && (false == opts->numeric)) { - opts->no_op = true; - debug("%s", "nothing to display - setting no_op"); + opts->no_display = true; + debug("%s", "nothing to display - setting no_display"); } /* @@ -259,7 +259,7 @@ int main(int argc, char **argv) pv_state_interval_set(state, opts->interval); pv_state_width_set(state, opts->width); pv_state_height_set(state, opts->height); - pv_state_no_op_set(state, opts->no_op); + pv_state_no_display_set(state, opts->no_display); pv_state_force_set(state, opts->force); pv_state_cursor_set(state, opts->cursor); pv_state_numeric_set(state, opts->numeric); diff --git a/src/main/options.c b/src/main/options.c index 81673b0..e0d6dbc 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -380,7 +380,7 @@ opts_t opts_parse(unsigned int argc, char **argv) numopts++; break; case 'q': - opts->no_op = true; + opts->no_display = true; numopts++; break; case 'c': diff --git a/src/pv/loop.c b/src/pv/loop.c index e56146e..0f38ea3 100644 --- a/src/pv/loop.c +++ b/src/pv/loop.c @@ -237,7 +237,7 @@ int pv_main_loop(pvstate_t state) next_update.tv_sec = cur_time.tv_sec - 1; } - if (state->no_op) + if (state->no_display) continue; /* @@ -322,7 +322,7 @@ int pv_main_loop(pvstate_t state) if (state->cursor) { pv_crs_fini(state); } else { - if ((!state->numeric) && (!state->no_op) + if ((!state->numeric) && (!state->no_display) && (state->display_visible)) pv_write_retry(STDERR_FILENO, "\n", 1); } diff --git a/src/pv/state.c b/src/pv/state.c index ca61bdf..658ba73 100644 --- a/src/pv/state.c +++ b/src/pv/state.c @@ -197,9 +197,9 @@ void pv_state_null_set(pvstate_t state, bool val) state->null = val; }; -void pv_state_no_op_set(pvstate_t state, bool val) +void pv_state_no_display_set(pvstate_t state, bool val) { - state->no_op = val; + state->no_display = val; }; void pv_state_skip_errors_set(pvstate_t state, unsigned int val)