From: Willem Jan Withagen Date: Thu, 15 Apr 2021 10:53:50 +0000 (+0200) Subject: blk/kernel: explicit assign to fields in struct X-Git-Tag: v17.1.0~1992^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40864%2Fhead;p=ceph.git blk/kernel: explicit assign to fields in struct 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`. It also prevents the wrong initialisation on FreeBSD Signed-off-by: Willem Jan Withagen --- diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 09a4b687ef06..0cf38dfa2410 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -94,8 +94,8 @@ int KernelDevice::_lock() int fd = fd_directs[WRITE_LIFE_NOT_SET]; uint64_t nr_tries = 0; for (;;) { - struct flock fl = { F_WRLCK, - SEEK_SET }; + struct flock fl = { .l_type = F_WRLCK, + .l_whence = SEEK_SET }; int r = ::fcntl(fd, F_OFD_SETLK, &fl); if (r < 0) { if (errno == EINVAL) {