From e5f2916b650252200c88374e8dc63b88db0613aa Mon Sep 17 00:00:00 2001 From: Christian Rosentreter Date: Tue, 16 Apr 2024 17:49:06 +0200 Subject: [PATCH] Fix problematic fdatasync() call on macOS The fdatasync call generates a "implicit declaration of function 'fdatasync' is invalid in C99" warning when building for macOS (it's nowhere to be found in the system includes), but linking will eventually work fine because there is an unrelated syscall by the same name (different prototype), so it's not doing what it should. So lets not use it. --- pcap/pcap_logger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pcap/pcap_logger.c b/pcap/pcap_logger.c index 8c0a9bb..8998881 100644 --- a/pcap/pcap_logger.c +++ b/pcap/pcap_logger.c @@ -54,7 +54,11 @@ static int init_pcap_logger(void *data) { } static int deinit_pcap_logger(void) { - fdatasync(pcap_fd); +#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) + fdatasync(pcap_fd); +#else + fsync(pcap_fd); +#endif close(pcap_fd); return 0; }