From 13e1bf7204810c5dd3fd014cbd2f28c7057ab22c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 27 Sep 2019 20:42:34 -0700 Subject: [PATCH] [clang-tidy] Replace C style casts with C++ ones Found with google-readability-casting Signed-off-by: Rosen Penev --- src/Context.cpp | 2 +- src/DOM.cpp | 4 ++-- src/Eval.cpp | 18 +++++++++--------- src/Filter.cpp | 14 +++++++------- src/Hooks.cpp | 2 +- src/Lexer.cpp | 48 +++++++++++++++++++++++------------------------ src/TDB2.cpp | 12 ++++++------ src/TLSClient.cpp | 8 ++++---- src/Task.cpp | 8 ++++---- src/Variant.cpp | 46 ++++++++++++++++++++++----------------------- src/ViewTask.cpp | 4 ++-- src/calc.cpp | 2 +- src/feedback.cpp | 2 +- src/sort.cpp | 2 +- 14 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 386f58170..937fc1e80 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -1035,7 +1035,7 @@ void Context::getLimits (int& rows, int& lines) } else { - rows = (int) strtol (limit.c_str (), nullptr, 10); + rows = static_cast(strtol (limit.c_str (), nullptr, 10)); lines = 0; } } diff --git a/src/DOM.cpp b/src/DOM.cpp index ed1be1b4a..6bb1d97b3 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -387,7 +387,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) { // annotation_1234567890 // 0 ^11 - value = Variant ((time_t) strtol (i.first.substr (11).c_str (), NULL, 10), Variant::type_date); + value = Variant (static_cast(strtol (i.first.substr (11).c_str (), NULL, 10)), Variant::type_date); return true; } else if (elements[2] == "description") @@ -646,7 +646,7 @@ std::string DOM::Node::dumpNode ( out << "\033[31m" << node->_name << "\033[0m"; if (node->_provider) - out << " 0x" << std::hex << (long long) (void*) node->_provider; + out << " 0x" << std::hex << (long long) reinterpret_cast(node->_provider); out << '\n'; diff --git a/src/Eval.cpp b/src/Eval.cpp index d2b9bfeff..8ad3484b6 100644 --- a/src/Eval.cpp +++ b/src/Eval.cpp @@ -237,7 +237,7 @@ void Eval::evaluatePostfixStack ( Variant result = ! right; values.push_back (result); if (_debug) - Context::getContext ().debug (format ("Eval {1} ↓'{2}' → ↑'{3}'", token.first, (std::string) right, (std::string) result)); + Context::getContext ().debug (format ("Eval {1} ↓'{2}' → ↑'{3}'", token.first, std::string(right), std::string(result))); } else if (token.second == Lexer::Type::op && token.first == "_neg_") @@ -253,7 +253,7 @@ void Eval::evaluatePostfixStack ( values.push_back (result); if (_debug) - Context::getContext ().debug (format ("Eval {1} ↓'{2}' → ↑'{3}'", token.first, (std::string) right, (std::string) result)); + Context::getContext ().debug (format ("Eval {1} ↓'{2}' → ↑'{3}'", token.first, std::string(right), std::string(result))); } else if (token.second == Lexer::Type::op && token.first == "_pos_") @@ -306,7 +306,7 @@ void Eval::evaluatePostfixStack ( values.push_back (result); if (_debug) - Context::getContext ().debug (format ("Eval ↓'{1}' {2} ↓'{3}' → ↑'{4}'", (std::string) left, token.first, (std::string) right, (std::string) result)); + Context::getContext ().debug (format ("Eval ↓'{1}' {2} ↓'{3}' → ↑'{4}'", std::string(left), token.first, std::string(right), std::string(result))); } // Literals and identifiers. @@ -320,13 +320,13 @@ void Eval::evaluatePostfixStack ( { v.cast (Variant::type_integer); if (_debug) - Context::getContext ().debug (format ("Eval literal number ↑'{1}'", (std::string) v)); + Context::getContext ().debug (format ("Eval literal number ↑'{1}'", std::string(v))); } else { v.cast (Variant::type_real); if (_debug) - Context::getContext ().debug (format ("Eval literal decimal ↑'{1}'", (std::string) v)); + Context::getContext ().debug (format ("Eval literal decimal ↑'{1}'", std::string(v))); } break; @@ -343,7 +343,7 @@ void Eval::evaluatePostfixStack ( if (_source (token.first, v)) { if (_debug) - Context::getContext ().debug (format ("Eval identifier source '{1}' → ↑'{2}'", token.first, (std::string) v)); + Context::getContext ().debug (format ("Eval identifier source '{1}' → ↑'{2}'", token.first, std::string(v))); found = true; break; } @@ -362,20 +362,20 @@ void Eval::evaluatePostfixStack ( case Lexer::Type::date: v.cast (Variant::type_date); if (_debug) - Context::getContext ().debug (format ("Eval literal date ↑'{1}'", (std::string) v)); + Context::getContext ().debug (format ("Eval literal date ↑'{1}'", std::string(v))); break; case Lexer::Type::duration: v.cast (Variant::type_duration); if (_debug) - Context::getContext ().debug (format ("Eval literal duration ↑'{1}'", (std::string) v)); + Context::getContext ().debug (format ("Eval literal duration ↑'{1}'", std::string(v))); break; // Nothing to do. case Lexer::Type::string: default: if (_debug) - Context::getContext ().debug (format ("Eval literal string ↑'{1}'", (std::string) v)); + Context::getContext ().debug (format ("Eval literal string ↑'{1}'", std::string(v))); break; } diff --git a/src/Filter.cpp b/src/Filter.cpp index 1bc606196..7a890d037 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -57,7 +57,7 @@ bool domSource (const std::string& identifier, Variant& value) void Filter::subset (const std::vector & input, std::vector & output) { Timer timer; - _startCount = (int) input.size (); + _startCount = static_cast(input.size ()); Context::getContext ().cli2.prepareFilter (); @@ -92,7 +92,7 @@ void Filter::subset (const std::vector & input, std::vector & output else output = input; - _endCount = (int) output.size (); + _endCount = static_cast(output.size ()); Context::getContext ().debug (format ("Filtered {1} tasks --> {2} tasks [list subset]", _startCount, _endCount)); Context::getContext ().time_filter_us += timer.total_us (); } @@ -117,7 +117,7 @@ void Filter::subset (std::vector & output) Timer timer_pending; auto pending = Context::getContext ().tdb2.pending.get_tasks (); Context::getContext ().time_filter_us -= timer_pending.total_us (); - _startCount = (int) pending.size (); + _startCount = static_cast(pending.size ()); Eval eval; eval.addSource (domSource); @@ -145,7 +145,7 @@ void Filter::subset (std::vector & output) Timer timer_completed; auto completed = Context::getContext ().tdb2.completed.get_tasks (); Context::getContext ().time_filter_us -= timer_completed.total_us (); - _startCount += (int) completed.size (); + _startCount += static_cast(completed.size ()); for (auto& task : completed) { @@ -174,7 +174,7 @@ void Filter::subset (std::vector & output) Context::getContext ().time_filter_us -= pending_completed.total_us (); } - _endCount = (int) output.size (); + _endCount = static_cast(output.size ()); Context::getContext ().debug (format ("Filtered {1} tasks --> {2} tasks [{3}]", _startCount, _endCount, (shortcut ? "pending only" : "all tasks"))); Context::getContext ().time_filter_us += timer.total_us (); } @@ -209,8 +209,8 @@ bool Filter::pendingOnly () const int countPending = 0; int countWaiting = 0; int countRecurring = 0; - int countId = (int) Context::getContext ().cli2._id_ranges.size (); - int countUUID = (int) Context::getContext ().cli2._uuid_list.size (); + int countId = static_cast(Context::getContext ().cli2._id_ranges.size ()); + int countUUID = static_cast(Context::getContext ().cli2._uuid_list.size ()); int countOr = 0; int countXor = 0; int countNot = 0; diff --git a/src/Hooks.cpp b/src/Hooks.cpp index a4929a07e..997936abb 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -471,7 +471,7 @@ void Hooks::assertNTasks ( { if (input.size () != n) { - Context::getContext ().error (format (STRING_HOOK_ERROR_BAD_NUM, n, (int) input.size (), Path (script).name ())); + Context::getContext ().error (format (STRING_HOOK_ERROR_BAD_NUM, n, static_cast(input.size ()), Path (script).name ())); throw 0; } } diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 1f769b37b..c9d70476a 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -355,7 +355,7 @@ std::string Lexer::commify (const std::string& data) int end = -1; int i; - for (int i = 0; i < (int) data.length (); ++i) + for (int i = 0; i < static_cast(data.length ()); ++i) { if (unicodeLatinDigit (data[i])) end = i; @@ -369,7 +369,7 @@ std::string Lexer::commify (const std::string& data) { // In reverse order, transfer all digits up to, and including the decimal // point. - for (i = (int) data.length () - 1; i >= decimalPoint; --i) + for (i = static_cast(data.length ()) - 1; i >= decimalPoint; --i) result += data[i]; int consecutiveDigits = 0; @@ -393,7 +393,7 @@ std::string Lexer::commify (const std::string& data) { // In reverse order, transfer all digits up to, but not including the last // digit. - for (i = (int) data.length () - 1; i > end; --i) + for (i = static_cast(data.length ()) - 1; i > end; --i) result += data[i]; int consecutiveDigits = 0; @@ -416,7 +416,7 @@ std::string Lexer::commify (const std::string& data) // reverse result into data. std::string done; - for (int i = (int) result.length () - 1; i >= 0; --i) + for (int i = static_cast(result.length ()) - 1; i >= 0; --i) done += result[i]; return done; @@ -1463,20 +1463,20 @@ bool Lexer::readWord ( switch (c) { - case '"': word += (char) 0x22; ++cursor; break; - case '\'': word += (char) 0x27; ++cursor; break; - case '\\': word += (char) 0x5C; ++cursor; break; - case 'b': word += (char) 0x08; ++cursor; break; - case 'f': word += (char) 0x0C; ++cursor; break; - case 'n': word += (char) 0x0A; ++cursor; break; - case 'r': word += (char) 0x0D; ++cursor; break; - case 't': word += (char) 0x09; ++cursor; break; - case 'v': word += (char) 0x0B; ++cursor; break; + case '"': word += static_cast(0x22); ++cursor; break; + case '\'': word += static_cast(0x27); ++cursor; break; + case '\\': word += static_cast(0x5C); ++cursor; break; + case 'b': word += static_cast(0x08); ++cursor; break; + case 'f': word += static_cast(0x0C); ++cursor; break; + case 'n': word += static_cast(0x0A); ++cursor; break; + case 'r': word += static_cast(0x0D); ++cursor; break; + case 't': word += static_cast(0x09); ++cursor; break; + case 'v': word += static_cast(0x0B); ++cursor; break; // This pass-through default case means that anything can be escaped // harmlessly. In particular 'quote' is included, if it not one of the // above characters. - default: word += (char) c; ++cursor; break; + default: word += static_cast(c); ++cursor; break; } } @@ -1547,20 +1547,20 @@ bool Lexer::readWord ( switch (c) { - case '"': word += (char) 0x22; ++cursor; break; - case '\'': word += (char) 0x27; ++cursor; break; - case '\\': word += (char) 0x5C; ++cursor; break; - case 'b': word += (char) 0x08; ++cursor; break; - case 'f': word += (char) 0x0C; ++cursor; break; - case 'n': word += (char) 0x0A; ++cursor; break; - case 'r': word += (char) 0x0D; ++cursor; break; - case 't': word += (char) 0x09; ++cursor; break; - case 'v': word += (char) 0x0B; ++cursor; break; + case '"': word += static_cast(0x22); ++cursor; break; + case '\'': word += static_cast(0x27); ++cursor; break; + case '\\': word += static_cast(0x5C); ++cursor; break; + case 'b': word += static_cast(0x08); ++cursor; break; + case 'f': word += static_cast(0x0C); ++cursor; break; + case 'n': word += static_cast(0x0A); ++cursor; break; + case 'r': word += static_cast(0x0D); ++cursor; break; + case 't': word += static_cast(0x09); ++cursor; break; + case 'v': word += static_cast(0x0B); ++cursor; break; // This pass-through default case means that anything can be escaped // harmlessly. In particular 'quote' is included, if it not one of the // above characters. - default: word += (char) c; ++cursor; break; + default: word += static_cast(c); ++cursor; break; } } diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 02b04f4a0..772e3db4a 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -577,12 +577,12 @@ std::string TF2::dump () // Hygiene. std::string hygiene = _dirty ? red.colorize ("O") : green.colorize ("-"); - std::string tasks = green.colorize (rightJustifyZero ((int) _tasks.size (), 4)); - std::string tasks_added = red.colorize (rightJustifyZero ((int) _added_tasks.size (), 3)); - std::string tasks_modified = yellow.colorize (rightJustifyZero ((int) _modified_tasks.size (), 3)); - std::string tasks_purged = red.colorize (rightJustifyZero ((int) _purged_tasks.size (), 3)); - std::string lines = green.colorize (rightJustifyZero ((int) _lines.size (), 4)); - std::string lines_added = red.colorize (rightJustifyZero ((int) _added_lines.size (), 3)); + std::string tasks = green.colorize (rightJustifyZero (static_cast(_tasks.size ()), 4)); + std::string tasks_added = red.colorize (rightJustifyZero (static_cast(_added_tasks.size ()), 3)); + std::string tasks_modified = yellow.colorize (rightJustifyZero (static_cast(_modified_tasks.size ()), 3)); + std::string tasks_purged = red.colorize (rightJustifyZero (static_cast(_purged_tasks.size ()), 3)); + std::string lines = green.colorize (rightJustifyZero (static_cast(_lines.size ()), 4)); + std::string lines_added = red.colorize (rightJustifyZero (static_cast(_added_lines.size ()), 3)); char buffer[256]; // Composed string is actually 246 bytes. Yikes. snprintf (buffer, 256, "%14s %s %s T%s+%s~%s-%s L%s+%s", diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index 993925691..820f34071 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -301,7 +301,7 @@ void TLSClient::connect (const std::string& host, const std::string& port) gnutls_datum_t out; gnutls_certificate_verification_status_print (status, type, &out, 0); // 3.1.4 - std::string error {(const char*) out.data}; + std::string error {reinterpret_cast(out.data)}; gnutls_free (out.data); // All throw format ("Handshake failed. {1}", error); // All @@ -484,8 +484,8 @@ void TLSClient::send (const std::string& data) if (status == -1) break; - total += (unsigned int) status; - remaining -= (unsigned int) status; + total += static_cast(status); + remaining -= static_cast(status); } if (_debug) @@ -564,7 +564,7 @@ void TLSClient::recv (std::string& data) if (_limit && total > _limit) break; } - while (received > 0 && total < (int) expected); + while (received > 0 && total < static_cast(expected)); if (_debug) std::cout << "c: INFO Receiving 'XXXX" diff --git a/src/Task.cpp b/src/Task.cpp index dcd694281..e60e1ee2d 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -181,7 +181,7 @@ std::string Task::identifier (bool shortened /* = false */) const void Task::setAsNow (const std::string& att) { char now[16]; - snprintf (now, 16, "%u", (unsigned int) time (nullptr)); + snprintf (now, 16, "%u", static_cast(time (nullptr))); set (att, now); recalc_urgency = true; @@ -261,7 +261,7 @@ time_t Task::get_date (const std::string& name) const { auto i = data.find (name); if (i != data.end ()) - return (time_t) strtoul (i->second.c_str (), nullptr, 10); + return static_cast(strtoul (i->second.c_str (), nullptr, 10)); return 0; } @@ -1065,7 +1065,7 @@ void Task::addAnnotation (const std::string& description) do { - key = "annotation_" + format ((int) now); + key = "annotation_" + format (static_cast(now)); ++now; } while (has (key)); @@ -1234,7 +1234,7 @@ std::vector Task::getDependencyTasks () const int Task::getTagCount () const { auto tags = split (get ("tags"), ','); - return (int) tags.size (); + return static_cast(tags.size ()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Variant.cpp b/src/Variant.cpp index 495282dce..abbdb81c0 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1181,7 +1181,7 @@ Variant& Variant::operator^= (const Variant& other) switch (other._type) { case type_boolean: throw std::string (STRING_VARIANT_EXP_BOOL); - case type_integer: _integer = (int) pow (static_cast(_integer), static_cast(other._integer)); break; + case type_integer: _integer = static_cast(pow (static_cast(_integer), static_cast(other._integer))); break; case type_real: throw std::string (STRING_VARIANT_EXP_NON_INT); case type_string: throw std::string (STRING_VARIANT_EXP_STRING); case type_date: throw std::string (STRING_VARIANT_EXP_DATE); @@ -1285,7 +1285,7 @@ Variant& Variant::operator-= (const Variant& other) { case type_boolean: right.cast (type_integer); _date -= right._integer; break; case type_integer: _date -= right._integer; break; - case type_real: _date -= (int) right._real; break; + case type_real: _date -= static_cast(right._real); break; case type_string: throw std::string (STRING_VARIANT_SUB_STRING); case type_date: cast (type_duration); _duration -= right._date; break; case type_duration: _date -= right._duration; break; @@ -1297,7 +1297,7 @@ Variant& Variant::operator-= (const Variant& other) { case type_boolean: right.cast (type_integer); _duration -= right._integer; break; case type_integer: _duration -= right._integer; break; - case type_real: _duration -= (int) right._real; break; + case type_real: _duration -= static_cast(right._real); break; case type_string: throw std::string (STRING_VARIANT_SUB_STRING); case type_date: throw std::string (STRING_VARIANT_SUB_DATE); case type_duration: _duration -= right._duration; break; @@ -1367,18 +1367,18 @@ Variant& Variant::operator+= (const Variant& other) case type_date: _type = type_date; - _date = (unsigned) (int) _real + right._date; + _date = static_cast(static_cast(_real)) + right._date; break; case type_duration: _type = type_duration; - _duration = (unsigned) (int) _real + right._duration; + _duration = static_cast(static_cast(_real)) + right._duration; break; } break; case type_string: - _string += (std::string) right; + _string += std::string(right); break; case type_date: @@ -1386,7 +1386,7 @@ Variant& Variant::operator+= (const Variant& other) { case type_boolean: right.cast (type_date); _date += right._date; break; case type_integer: _date += right._integer; break; - case type_real: _date += (int) right._real; break; + case type_real: _date += static_cast(right._real); break; case type_string: cast (type_string); _string += right._string; break; case type_date: throw std::string (STRING_VARIANT_ADD_DATE); case type_duration: _date += right._duration; break; @@ -1398,7 +1398,7 @@ Variant& Variant::operator+= (const Variant& other) { case type_boolean: right.cast (type_duration); _duration += right._duration; break; case type_integer: _duration += right._integer; break; - case type_real: _duration += (int) right._real; break; + case type_real: _duration += static_cast(right._real); break; case type_string: cast (type_string); _string += right._string; break; case type_date: cast (type_date); _date += right._date; break; case type_duration: _duration += right._duration; break; @@ -1478,7 +1478,7 @@ Variant& Variant::operator*= (const Variant& other) case type_duration: _type = type_duration; - _duration = (time_t) (unsigned) (int) (_real * static_cast(right._duration)); + _duration = static_cast(static_cast(static_cast(_real * static_cast(right._duration)))); } break; @@ -1511,7 +1511,7 @@ Variant& Variant::operator*= (const Variant& other) case type_boolean: right.cast (type_duration); _duration *= right._duration; break; case type_integer: _duration *= right._integer; break; case type_real: - _duration = (time_t) (unsigned) (int) (static_cast(_duration) * right._real); + _duration = static_cast(static_cast(static_cast(static_cast(_duration) * right._real))); break; case type_string: throw std::string (STRING_VARIANT_MUL_DUR_STR); case type_date: throw std::string (STRING_VARIANT_MUL_DUR_DATE); @@ -1571,7 +1571,7 @@ Variant& Variant::operator/= (const Variant& other) if (right._duration == 0) throw std::string (STRING_VARIANT_DIV_ZERO); _type = type_duration; - _duration = (time_t) (unsigned) (int) (_integer / right._duration); + _duration = static_cast(static_cast(static_cast(_integer / right._duration))); break; } break; @@ -1604,7 +1604,7 @@ Variant& Variant::operator/= (const Variant& other) if (right._duration == 0) throw std::string (STRING_VARIANT_DIV_ZERO); _type = type_duration; - _duration = (time_t) (unsigned) (int) (_real / right._duration); + _duration = static_cast(static_cast(static_cast(_real / right._duration))); break; } break; @@ -1631,7 +1631,7 @@ Variant& Variant::operator/= (const Variant& other) case type_real: if (right._real == 0) throw std::string (STRING_VARIANT_DIV_ZERO); - _duration = (time_t) (unsigned) (int) (static_cast(_duration) / right._real); + _duration = static_cast(static_cast(static_cast(static_cast(_duration) / right._real))); break; case type_string: @@ -1830,8 +1830,8 @@ void Variant::cast (const enum type new_type) _string = temp; } break; - case type_date: _date = (time_t) _integer; break; - case type_duration: _duration = (time_t) _integer; break; + case type_date: _date = static_cast(_integer); break; + case type_duration: _duration = static_cast(_integer); break; } break; @@ -1839,7 +1839,7 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _real == 0.0 ? false : true; break; - case type_integer: _integer = (int) _real; break; + case type_integer: _integer = static_cast(_real); break; case type_real: break; case type_string: { @@ -1848,8 +1848,8 @@ void Variant::cast (const enum type new_type) _string = temp; } break; - case type_date: _date = (time_t) (int) _real; break; - case type_duration: _duration = (time_t) (int) _real; break; + case type_date: _date = static_cast(static_cast(_real)); break; + case type_duration: _duration = static_cast(static_cast(_real)); break; } break; @@ -1863,7 +1863,7 @@ void Variant::cast (const enum type new_type) _string == "0.0") ? false : true; break; case type_integer: - _integer = (int) strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)); + _integer = static_cast(strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10))); break; case type_real: _real = strtod (_string.c_str (), nullptr); break; case type_string: break; @@ -1914,9 +1914,9 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _date != 0 ? true : false; break; - case type_integer: _integer = (int) _date; break; + case type_integer: _integer = static_cast(_date); break; case type_real: _real = static_cast(_date); break; - case type_string: _string = (std::string) *this; break; + case type_string: _string = std::string(*this); break; case type_date: break; case type_duration: _duration = _date; break; } @@ -1926,9 +1926,9 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _duration != 0 ? true : false; break; - case type_integer: _integer = (int) _duration; break; + case type_integer: _integer = static_cast(_duration); break; case type_real: _real = static_cast(_duration); break; - case type_string: _string = (std::string) *this; break; + case type_string: _string = std::string(*this); break; case type_date: _date = _duration; break; case type_duration: break; } diff --git a/src/ViewTask.cpp b/src/ViewTask.cpp index 68bd253a1..28244d7c9 100644 --- a/src/ViewTask.cpp +++ b/src/ViewTask.cpp @@ -127,10 +127,10 @@ std::string ViewTask::render (std::vector & data, std::vector & seque for (unsigned int s = 0; s < sequence.size (); ++s) { - if ((int)s >= _truncate_lines && _truncate_lines != 0) + if (static_cast(s) >= _truncate_lines && _truncate_lines != 0) break; - if ((int)s >= _truncate_rows && _truncate_rows != 0) + if (static_cast(s) >= _truncate_rows && _truncate_rows != 0) break; // Determine minimum and ideal width for this column. diff --git a/src/calc.cpp b/src/calc.cpp index e4ef01229..de474106c 100644 --- a/src/calc.cpp +++ b/src/calc.cpp @@ -123,7 +123,7 @@ int main (int argc, char** argv) std::cout << i << '\n'; // Show the result in string form. - std::cout << (std::string) result + std::cout << std::string(result) << '\n'; } diff --git a/src/feedback.cpp b/src/feedback.cpp index 781a3eff4..8e4f7f758 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -248,7 +248,7 @@ std::string renderAttribute (const std::string& name, const std::string& value, col->type () == "date" && !value.empty()) { - Datetime d ((time_t)strtol (value.c_str (), nullptr, 10)); + Datetime d (static_cast(strtol (value.c_str (), nullptr, 10))); if (format.empty()) return d.toString (Context::getContext ().config.get ("dateformat")); diff --git a/src/sort.cpp b/src/sort.cpp index df71a1804..a55ec1cbd 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -99,7 +99,7 @@ void sort_projects ( { std::map allProjectsInt; for (auto& p : allProjects) - allProjectsInt[p.first] = (int) p.second; + allProjectsInt[p.first] = static_cast(p.second); sort_projects (sorted, allProjectsInt); }