Fix compiler warnings (#1081)

* Fix narrowing conversion warning.

The `static_cast` does not change the behavior of the programm only explictly stating that the behavior is intended.
This change is needed as some compiler settings will treat this warning as an error.

* Do not redeclare `result` variable in insertFormattedString as it shadows variable in outer scope.

This fixes a compiler warning for shadowing variables declared in an outer scope. This change does not change the behaviour of the programm as the shadowd variable is not reused after the inner scope ends. Also the new version should represent the intention of the code better.
This change is needed as some compiler settings will treat this warning as an error.
This commit is contained in:
L0ric0 2021-11-21 02:14:57 +01:00 committed by GitHub
parent e4ec2c36c5
commit 953000e3fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -107,10 +107,10 @@ class DROGON_EXPORT HttpViewData
} }
va_copy(backup_ap, ap); va_copy(backup_ap, ap);
auto result = vsnprintf((char *)strBuffer.data(), result = vsnprintf((char *)strBuffer.data(),
strBuffer.size(), strBuffer.size(),
format, format,
backup_ap); backup_ap);
va_end(backup_ap); va_end(backup_ap);
if ((result >= 0) && if ((result >= 0) &&

View File

@ -395,7 +395,9 @@ inline bool fromString<bool>(const std::string &p) noexcept(false)
return false; return false;
} }
std::string l{p}; std::string l{p};
std::transform(p.begin(), p.end(), l.begin(), tolower); std::transform(p.begin(), p.end(), l.begin(), [](unsigned char ch) {
return static_cast<unsigned char>(tolower(ch));
});
if (l == "true") if (l == "true")
{ {
return true; return true;

View File

@ -225,7 +225,7 @@ inline int8_t Field::as<int8_t>() const
{ {
if (isNull()) if (isNull())
return 0; return 0;
return atoi(result_.getValue(row_, column_)); return static_cast<int8_t>(atoi(result_.getValue(row_, column_)));
} }
template <> template <>