From: Willem Jan Withagen Date: Thu, 15 Apr 2021 11:01:21 +0000 (+0200) Subject: core: fix compiler warning due to difference in order of struct memebers X-Git-Tag: v17.1.0~2215^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40872%2Fhead;p=ceph.git 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 --- diff --git a/src/global/pidfile.cc b/src/global/pidfile.cc index 6a6b939f1138..c46ad2b30363 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) {