Clarify cast in easylogging++

`tval.tv_usec` is a (signed) `long` and `ssPrec->m_offset` is an
`unsigned int`. Clang warns upon realizing that we are attempting to
divide a signed `long` with an `unsigned int`.

Casting the `long` to `unsigned long` makes both operands `unsigned` and
allows for auto conversion to `size_t`.

The `size_t` cast is to make it apparent that the cast is correct.
This commit is contained in:
Vasily
2019-02-21 18:48:53 +01:00
committed by username223
parent 4814c4686f
commit dbb1ab70e5
+1 -1
View File
@@ -1190,7 +1190,7 @@ std::string DateTime::timevalToString(struct timeval tval, const char* format,
buildTimeInfo(&tval, &timeInfo);
const int kBuffSize = 30;
char buff_[kBuffSize] = "";
parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast<unsigned long>(tval.tv_usec) / ssPrec->m_offset,
parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast<size_t>(static_cast<unsigned long>(tval.tv_usec) / ssPrec->m_offset),
ssPrec);
return std::string(buff_);
}