From 3cfe113a60d9ed2b1fa18293c9d9660c638d9368 Mon Sep 17 00:00:00 2001 From: Kristofer Rye Date: Sun, 7 Jun 2020 17:22:36 -0500 Subject: [PATCH] builtin_string: Remove redundant condition in handle_flag_f The removed comparison ({begin,end,field} == INT_MIN) always evaluates to false, because at this point in evaluation, `begin <= 0` has already been evaluated to be false. Since INT_MIN <= 0, the second conditional in all three of the affected cases is always false. The C++ standard seems to guarantee left-to-right evaluation of logical operators, but not necessarily bitwise operators. Signed-off-by: Kristofer Rye --- src/builtin_string.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 39b9c8ec0..db8de1f11 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -280,7 +280,7 @@ static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams wcstring_list_t range = split_string(s, L'-'); if (range.size() == 2) { int begin = fish_wcstoi(range.at(0).c_str()); - if (begin <= 0 || begin == INT_MIN || errno == ERANGE) { + if (begin <= 0 || errno == ERANGE) { string_error(streams, _(L"%ls: Invalid range value for field '%ls'\n"), argv[0], w.woptarg); return STATUS_INVALID_ARGS; @@ -289,7 +289,7 @@ static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } int end = fish_wcstoi(range.at(1).c_str()); - if (end <= 0 || end == INT_MIN || errno == ERANGE) { + if (end <= 0 || errno == ERANGE) { string_error(streams, _(L"%ls: Invalid range value for field '%ls'\n"), argv[0], w.woptarg); return STATUS_INVALID_ARGS; @@ -308,7 +308,7 @@ static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams } } else { int field = fish_wcstoi(s.c_str()); - if (field <= 0 || field == INT_MIN || errno == ERANGE) { + if (field <= 0 || errno == ERANGE) { string_error(streams, _(L"%ls: Invalid fields value '%ls'\n"), argv[0], w.woptarg); return STATUS_INVALID_ARGS;