summaryrefslogtreecommitdiff
path: root/http/utility.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-02-18 05:06:04 +0300
committerEd Tanous <ed@tanous.net>2022-03-02 06:08:58 +0300
commit4656063c7a0e7fa12597e8f2ee7e891b62cb69e2 (patch)
tree388d3da6593c6bedd82ed1b25c6bb6c7eae3b949 /http/utility.hpp
parent4068129a6cbde8ee8d00a5254ef0961b2b4812e2 (diff)
downloadbmcweb-4656063c7a0e7fa12597e8f2ee7e891b62cb69e2.tar.xz
Fix constexpr on clang
clang correctly notes that this branch is impossible to hit on 32 bit systems, so wrap it in an if contexpr check to check for 32 bit, and avoid the next branch entirely. Tested: code compiles further on clang. Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iccaab8402d839faa7c3f7cea457ef6bcba832f67
Diffstat (limited to 'http/utility.hpp')
-rw-r--r--http/utility.hpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/http/utility.hpp b/http/utility.hpp
index 37c06cd7ed..6c4cfb706e 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -616,9 +616,12 @@ inline std::string getDateTimeUintMs(uint64_t milliSecondsSinceEpoch)
inline std::string getDateTimeStdtime(std::time_t secondsSinceEpoch)
{
- if (secondsSinceEpoch > static_cast<int64_t>(details::maxSeconds))
+ constexpr static std::time_t timeTMax =
+ std::numeric_limits<std::time_t>::max();
+ if constexpr (std::cmp_greater(timeTMax, details::maxSeconds))
{
- secondsSinceEpoch = static_cast<std::time_t>(details::maxSeconds);
+ secondsSinceEpoch = std::min(static_cast<int64_t>(details::maxSeconds),
+ secondsSinceEpoch);
}
boost::posix_time::ptime time =
boost::posix_time::from_time_t(secondsSinceEpoch);