From c4613f9c1bde288b43137738a7c0468e7a536840 Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Thu, 15 Apr 2021 13:01:21 +0200 Subject: [PATCH] core: fix compiler warning due to difference in order of struct memebers Clang on FreeBSD reports: ``` Building CXX object src/global/CMakeFiles/libglobal_objs.dir/pidfile.cc.o ../src/global/pidfile.cc:170:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'l_whence' will be initialized after field 'l_start' [-Wreorder-init-list] .l_start = 0, ^~~~~~~~~~~~ ../src/global/pidfile.cc:169:17: note: previous initialization for field 'l_whence' is here .l_whence = SEEK_SET, ^~~~~~~~ ``` And Linux and BSD have different orders in their `struct flock` Signed-off-by: Willem Jan Withagen --- src/global/pidfile.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/global/pidfile.cc b/src/global/pidfile.cc index 6a6b939f11380..c46ad2b303636 100644 --- a/src/global/pidfile.cc +++ b/src/global/pidfile.cc @@ -164,12 +164,12 @@ int pidfh::open(std::string_view pid_file) // Default Windows file share flags prevent other processes from writing // to this file. #ifndef _WIN32 - struct flock l = { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 0 - }; + struct flock l; + l.l_type = F_WRLCK; + l.l_whence = SEEK_SET; + l.l_start = 0; + l.l_len = 0; + int r = ::fcntl(pf_fd, F_SETLK, &l); if (r < 0) { if (errno == EAGAIN || errno == EACCES) { -- 2.39.5