From e4a7e7d4f730c63b27020c12b662fe74d5f46e60 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 25 Nov 2019 17:31:57 -0800 Subject: [PATCH] [clang-tidy] Use strcmp family properly Found with bugprone-suspicious-string-compare Signed-off-by: Rosen Penev --- src/builtin_functions.cpp | 2 +- src/env_dispatch.cpp | 2 +- src/history_file.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builtin_functions.cpp b/src/builtin_functions.cpp index f25a3377c..f189bd3e2 100644 --- a/src/builtin_functions.cpp +++ b/src/builtin_functions.cpp @@ -258,7 +258,7 @@ static int report_function_metadata(const wchar_t *funcname, bool verbose, io_st } if (metadata_as_comments) { - if (std::wcscmp(path, L"stdin")) { + if (std::wcscmp(path, L"stdin") != 0) { wcstring comment; append_format(comment, L"# Defined in %ls @ line %d\n", path, line_number); if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) { diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index c3b959d4b..1a747c677 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -507,7 +507,7 @@ static void init_locale(const environment_t &vars) { FLOGF(env_locale, L"old LC_MESSAGES locale: '%s'", old_msg_locale); FLOGF(env_locale, L"new LC_MESSAGES locale: '%s'", new_msg_locale); #ifdef HAVE__NL_MSG_CAT_CNTR - if (std::strcmp(old_msg_locale, new_msg_locale)) { + if (std::strcmp(old_msg_locale, new_msg_locale) != 0) { // Make change known to GNU gettext. extern int _nl_msg_cat_cntr; _nl_msg_cat_cntr++; diff --git a/src/history_file.cpp b/src/history_file.cpp index 7ab551f56..453c96dac 100644 --- a/src/history_file.cpp +++ b/src/history_file.cpp @@ -265,7 +265,7 @@ static history_item_t decode_item_fish_2_0(const char *base, size_t len) { size_t advance = read_line(base, cursor, len, line); if (trim_leading_spaces(line) <= indent) break; - if (std::strncmp(line.c_str(), "- ", 2)) break; + if (std::strncmp(line.c_str(), "- ", 2) != 0) break; // We're going to consume this line. cursor += advance;