diff options
author | Julian Andres Klode <jak@debian.org> | 2022-09-21 10:42:58 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2022-09-21 10:42:58 +0000 |
commit | 6bc11782aba64e9eeb33fbb2542d2597bb710a8e (patch) | |
tree | 06458e86df6094d3e03984d3330d4f15159ea4d4 | |
parent | 6499f7dc842ebd621f11ea01e83ccbe4125a0581 (diff) | |
parent | 81a5256298f1e4403591bdaf95957e832da75d31 (diff) |
Merge branch 'clang15' into 'main'
typecast time_t and suseconds_t from std::chrono
See merge request apt-team/apt!259
-rw-r--r-- | apt-pkg/acquire.cc | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/progress.cc | 2 | ||||
-rw-r--r-- | ftparchive/apt-ftparchive.cc | 2 | ||||
-rw-r--r-- | test/interactive-helper/libnoprofile.c | 1 |
4 files changed, 5 insertions, 4 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 100ccde32..dd0624ad6 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -53,11 +53,11 @@ using namespace std; // helper to convert time_point to a timeval -static struct timeval SteadyDurationToTimeVal(std::chrono::steady_clock::duration Time) +constexpr struct timeval SteadyDurationToTimeVal(std::chrono::steady_clock::duration Time) { auto const Time_sec = std::chrono::duration_cast<std::chrono::seconds>(Time); auto const Time_usec = std::chrono::duration_cast<std::chrono::microseconds>(Time - Time_sec); - return {Time_sec.count(), Time_usec.count()}; + return timeval{static_cast<time_t>(Time_sec.count()), static_cast<suseconds_t>(Time_usec.count())}; } std::string pkgAcquire::URIEncode(std::string const &part) /*{{{*/ diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 03f88d4ce..eb688b9a2 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -122,7 +122,7 @@ bool OpProgress::CheckChange(float Interval) auto const Now = std::chrono::steady_clock::now().time_since_epoch(); auto const Now_sec = std::chrono::duration_cast<std::chrono::seconds>(Now); auto const Now_usec = std::chrono::duration_cast<std::chrono::microseconds>(Now - Now_sec); - struct timeval NowTime = { Now_sec.count(), Now_usec.count() }; + struct timeval NowTime = { static_cast<time_t>(Now_sec.count()), static_cast<suseconds_t>(Now_usec.count()) }; std::chrono::duration<decltype(Interval)> Delta = std::chrono::seconds(NowTime.tv_sec - LastTime.tv_sec) + diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc index 87ce9153c..bbba0834b 100644 --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@ -53,7 +53,7 @@ static struct timeval GetTimevalFromSteadyClock() /*{{{*/ auto const Time = std::chrono::steady_clock::now().time_since_epoch(); auto const Time_sec = std::chrono::duration_cast<std::chrono::seconds>(Time); auto const Time_usec = std::chrono::duration_cast<std::chrono::microseconds>(Time - Time_sec); - return { Time_sec.count(), Time_usec.count() }; + return { static_cast<time_t>(Time_sec.count()), static_cast<suseconds_t>(Time_usec.count()) }; } /*}}}*/ static auto GetTimeDeltaSince(struct timeval StartTime) /*{{{*/ diff --git a/test/interactive-helper/libnoprofile.c b/test/interactive-helper/libnoprofile.c index f11b89899..b26ec2a1c 100644 --- a/test/interactive-helper/libnoprofile.c +++ b/test/interactive-helper/libnoprofile.c @@ -1,4 +1,5 @@ #define _GNU_SOURCE +#undef _FORTIFY_SOURCE #include <stdarg.h> #include <stdlib.h> #include <string.h> |