diff --git a/src/common.cpp b/src/common.cpp index bdf327018..d5647d9a8 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -287,11 +287,10 @@ std::string wcs2string(const wcstring &input) { for (size_t i = 0; i < input.size(); i++) { wchar_t wc = input[i]; if (wc == INTERNAL_SEPARATOR) { - // Do nothing. + ; // do nothing } else if (wc >= ENCODE_DIRECT_BASE && wc < ENCODE_DIRECT_BASE + 256) { result.push_back(wc - ENCODE_DIRECT_BASE); - } else if (MB_CUR_MAX == 1) // single-byte locale (C/POSIX/ISO-8859) - { + } else if (MB_CUR_MAX == 1) { // single-byte locale (C/POSIX/ISO-8859) // If `wc` contains a wide character we emit a question-mark. if (wc & ~0xFF) { wc = '?'; @@ -328,7 +327,7 @@ static char *wcs2str_internal(const wchar_t *in, char *out) { while (in[in_pos]) { if (in[in_pos] == INTERNAL_SEPARATOR) { - // Do nothing. + ; // do nothing } else if (in[in_pos] >= ENCODE_DIRECT_BASE && in[in_pos] < ENCODE_DIRECT_BASE + 256) { out[out_pos++] = in[in_pos] - ENCODE_DIRECT_BASE; } else if (MB_CUR_MAX == 1) // single-byte locale (C/POSIX/ISO-8859) diff --git a/src/complete.cpp b/src/complete.cpp index 2f750f412..5d54463ec 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -679,11 +679,11 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool } } - // WTF? This seems to be a noop. - if (use_implicit_cd && - !expand_string(str_cmd, &this->completions, - EXPAND_FOR_COMPLETIONS | DIRECTORIES_ONLY | this->expand_flags(), NULL)) { - // Not valid as implicit cd. + if (use_implicit_cd) { + // We don't really care if this succeeds or fails. If it succeeds this->completions will be + // updated with choices for the user. + (void)expand_string(str_cmd, &this->completions, + EXPAND_FOR_COMPLETIONS | DIRECTORIES_ONLY | this->expand_flags(), NULL); } if (str_cmd.find(L'/') == wcstring::npos && str_cmd.at(0) != L'~') { diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index ed70a54d5..69d0a2d3e 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -979,11 +979,8 @@ wcstring get_machine_identifier() { for (size_t i = 0; i < MAC_ADDRESS_MAX_LEN; i++) { append_format(result, L"%02x", mac_addr[i]); } - } else if (get_hostname_identifier(&result)) { - // Hooray - } else { - // Fallback - result.assign(L"nohost"); + } else if (!get_hostname_identifier(&result)) { + result.assign(L"nohost"); // fallback to a dummy value } return result; } diff --git a/src/expand.cpp b/src/expand.cpp index 26d2a5f6d..946f537f2 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -1386,7 +1386,7 @@ static expand_error_t expand_stage_wildcards(const wcstring &input, std::vector< const bool has_wildcard = wildcard_has(path_to_expand, true /* internal, i.e. ANY_CHAR */); if (has_wildcard && (flags & EXECUTABLES_ONLY)) { - // Don't do wildcard expansion for executables. See #785. Make them expand to nothing here. + ; // don't do wildcard expansion for executables, see issue #785 } else if (((flags & EXPAND_FOR_COMPLETIONS) && (!(flags & EXPAND_SKIP_WILDCARDS))) || has_wildcard) { // We either have a wildcard, or we don't have a wildcard but we're doing completion diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 071f51f7c..213eb9a75 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -988,7 +988,7 @@ bool parse_ll_t::top_node_handle_terminal_types(parse_token_t token) { } else if (stack_top.keyword == parse_keyword_end && token.type == parse_token_type_terminate && this->report_error_for_unclosed_block()) { - // Handled by report_error_for_unclosed_block. + ; // handled by report_error_for_unclosed_block } else { const wcstring expected = stack_top.user_presentable_description(); this->parse_error_unexpected_token(expected.c_str(), token); diff --git a/src/proc.cpp b/src/proc.cpp index 00b1db12d..6fdebdc15 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -336,10 +336,13 @@ static void handle_child_status(pid_t pid, int status) { } } +#if 0 + // TODO: decide whether to eliminate this block or have it emit a warning message. if (!found_proc) { // A child we lost track of? There have been bugs in both subshell handling and in builtin // handling that have caused this previously... } +#endif return; } diff --git a/src/reader.cpp b/src/reader.cpp index 0d981be16..e7e046236 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2205,7 +2205,7 @@ static void reader_super_highlight_me_plenty(int match_highlight_pos_adjust, boo const wcstring &cmd = el->text, &suggest = data->autosuggestion; if (can_autosuggest() && !suggest.empty() && string_prefixes_string_case_insensitive(cmd, suggest)) { - // The autosuggestion is still reasonable, so do nothing. + ; // the autosuggestion is still reasonable, so do nothing } else { update_autosuggestion(); } diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 38f226a1b..11bd751b3 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -385,9 +385,7 @@ static bool wildcard_test_flags_then_complete(const wcstring &filepath, const wc int stat_res = -1; int stat_errno = 0; int lstat_res = lwstat(filepath, &lstat_buf); - if (lstat_res < 0) { - // lstat failed. - } else { + if (lstat_res >= 0) { if (S_ISLNK(lstat_buf.st_mode)) { stat_res = wstat(filepath, &stat_buf);