From 59fe34ee36368bb28c8298b1a1bfad5d0d9f47a3 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Fri, 25 Oct 2024 00:10:36 +0200 Subject: treewide: Suppress clang-tidy warning if we already use O_CLOEXEC In pcap_init(), we should always open the packet capture file with O_CLOEXEC, even if we're not running in foreground: O_CLOEXEC means close-on-exec, not close-on-fork. In logfile_init() and pidfile_open(), the fact that we pass a third 'mode' argument to open() seems to confuse the android-cloexec-open checker in LLVM versions from 16 to 19 (at least). The checker is suggesting to add O_CLOEXEC to 'mode', and not in 'flags', where we already have it. Add a suppression for clang-tidy and a comment, and avoid repeating those three times by adding a new helper, output_file_open(). Signed-off-by: Stefano Brivio --- log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'log.c') diff --git a/log.c b/log.c index 6932885..19f1d98 100644 --- a/log.c +++ b/log.c @@ -416,8 +416,7 @@ void logfile_init(const char *name, const char *path, size_t size) if (readlink("/proc/self/exe", exe, PATH_MAX - 1) < 0) die_perror("Failed to read own /proc/self/exe link"); - log_file = open(path, O_CREAT | O_TRUNC | O_APPEND | O_RDWR | O_CLOEXEC, - S_IRUSR | S_IWUSR); + log_file = output_file_open(path, O_APPEND | O_RDWR); if (log_file == -1) die_perror("Couldn't open log file %s", path); -- cgit v1.2.3