From 8ea2be264872b59a3f920b4afeacf85e2c1ca72e Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Thu, 7 Apr 2022 09:24:39 -0700 Subject: [PATCH] decrease scope of a couple variables, prefix incr non-primitives --- src/builtins/string.cpp | 3 +-- src/common.cpp | 3 ++- src/exec.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/builtins/string.cpp b/src/builtins/string.cpp index c39ded228..c45c1e717 100644 --- a/src/builtins/string.cpp +++ b/src/builtins/string.cpp @@ -536,9 +536,8 @@ static int handle_flag_V(const wchar_t **argv, parser_t &parser, io_streams_t &s static int handle_flag_w(const wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { - long width = 0; if (opts->width_valid) { - width = fish_wcstol(w.woptarg); + long width = fish_wcstol(w.woptarg); if (width < 0) { string_error(streams, _(L"%ls: Invalid width value '%ls'\n"), argv[0], w.woptarg); return STATUS_INVALID_ARGS; diff --git a/src/common.cpp b/src/common.cpp index 4b5924c5c..95a81657b 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -681,12 +681,13 @@ void narrow_string_safe(char buff[64], const wchar_t *s) { wcstring reformat_for_screen(const wcstring &msg, const termsize_t &termsize) { wcstring buff; - int line_width = 0; + int screen_width = termsize.width; if (screen_width) { const wchar_t *start = msg.c_str(); const wchar_t *pos = start; + int line_width = 0; while (true) { int overflow = 0; diff --git a/src/exec.cpp b/src/exec.cpp index 212a711b2..77e2fd2b8 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -427,7 +427,7 @@ static launch_result_t fork_child_for_process(const std::shared_ptr &job, DIE("Child process returned control to fork_child lambda!"); } - s_fork_count++; + ++s_fork_count; FLOGF(exec_fork, L"Fork #%d, pid %d: %s for '%ls'", int(s_fork_count), pid, fork_type, p->argv0()); return launch_result_t::ok; @@ -527,7 +527,7 @@ static launch_result_t exec_external_command(parser_t &parser, const std::shared #if FISH_USE_POSIX_SPAWN // Prefer to use posix_spawn, since it's faster on some systems like OS X. if (can_use_posix_spawn_for_job(j, dup2s)) { - s_fork_count++; // spawn counts as a fork+exec + ++s_fork_count; // spawn counts as a fork+exec posix_spawner_t spawner(j.get(), dup2s); maybe_t pid = spawner.spawn(actual_cmd, const_cast(argv),