On Fri, Oct 25, 2024 at 01:04:36AM +0200, Stefano
Brivio wrote:
For clock_gettime(), we shouldn't ignore
errors if they happen at
initialisation phase, because something is seriously wrong and it's
not helpful if we proceed as if nothing happened.
As we're up and running, though, it's probably better to use a stale
value than to terminate altogether. Make sure we use a zero value if
we don't have a stale one somewhere.
For timerfd_gettime() and timerfd_settime() failures, report an error,
there isn't much else we can do.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
passt.c | 8 +++++---
pcap.c | 12 ++++++------
tcp.c | 12 +++++++++---
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/passt.c b/passt.c
index ad6f0bc..e987f0d 100644
--- a/passt.c
+++ b/passt.c
@@ -207,7 +207,8 @@ int main(int argc, char **argv)
struct timespec now;
struct sigaction sa;
- clock_gettime(CLOCK_MONOTONIC, &log_start);
+ if (clock_gettime(CLOCK_MONOTONIC, &log_start))
+ die_perror("Failed to get CLOCK_MONOTONIC time");
arch_avx2_exec(argv);
@@ -265,7 +266,8 @@ int main(int argc, char **argv)
secret_init(&c);
- clock_gettime(CLOCK_MONOTONIC, &now);
+ if (clock_gettime(CLOCK_MONOTONIC, &now))
+ die_perror("Failed to get CLOCK_MONOTONIC time");
flow_init();
@@ -313,7 +315,7 @@ loop:
if (nfds == -1 && errno != EINTR)
die_perror("epoll_wait() failed in main loop");
- clock_gettime(CLOCK_MONOTONIC, &now);
+ (void)clock_gettime(CLOCK_MONOTONIC, &now);
I think we should err() here.
Oops, right, added here and below.
--
Stefano