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:
+1
-1
@@ -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_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user